You are not logged in.

#1 2021-03-15 03:21:51

k395
Member
Registered: 2020-01-29
Posts: 37

[SOLVED] Home/End in `:term` inside vim inside xterm output 7/1

Reproduce:

* Compile the file in the wiki (xterm-screen-256color
https://wiki.archlinux.org/index.php/Tmux#xterm-keys
) with `tic`
* add the following to ~/.tmux.conf (as suggested in the wiki)

set-option -g xterm-keys on
set -g default-terminal xterm-screen-256color

(although I don't really understand what "xterm-style" mean, the escape sequences
for Home and End appear to be the same regardless of whether the option is set)

Edit: Yes, the wiki doesn't explain it, and the man page only say "xterm-style".
Although it appears that in the current version xterm-keys is the default.

As before, the default `$TERM` is `screen`, but the change is suggested
in the wiki so it should be fine. `$TERM` outside `tmux` is `xterm-256color`
(I changed Xresources as suggested in the wiki
https://wiki.archlinux.org/index.php/Xt … l_Variable )

Of course I tried `set-window-option -g xterm-keys on` too. (although `set-window-option`
is not listed in tmux's man page, I suppose it's an old option)

  • Open xterm

  • Open tmux. Observe that `echo $TERM` gives `xterm-screen-256color` now, and
    control+left/right and home/end works correctly.

  • Open `vim --clean`. control+left/right and home/end *still* works correctly.

  • Execute `:term` in it. Home and End results in `7` and `1` respectively now.
    Even <ctrl+v> <home> results in 7.
    Control+left/right still works.

Last edited by k395 (2022-01-29 08:11:49)

Offline

#2 2021-03-15 08:51:19

k395
Member
Registered: 2020-01-29
Posts: 37

Re: [SOLVED] Home/End in `:term` inside vim inside xterm output 7/1

... the issue persists even without tmux, xterm is sufficient.
I'll look into the configuration files to see if there's anything stand out.

`xrdb /dev/null` doesn't fix the issue. Neither does deleting `.bashrc`.

The issue in

https://old.reddit.com/r/vim/comments/8 … hen_using/

might be similar. However the issue I'm having does happen in xterm even if tmux server is killed.

Last edited by k395 (2021-03-15 08:59:53)

Offline

#3 2021-03-15 12:36:27

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 72,033

Re: [SOLVED] Home/End in `:term` inside vim inside xterm output 7/1

Please don't bump. If nobody replied, edit your post to mend it.
Since you figured late that it's not tmux related, are we sure it's vim:term related?
Is the $SHELL actually bash or zsh?
What's the $TERM inside the vim terminal in comparism to the plain xterm?

Offline

#4 2021-03-15 13:16:51

k395
Member
Registered: 2020-01-29
Posts: 37

Re: [SOLVED] Home/End in `:term` inside vim inside xterm output 7/1

Okay.
The issue doesn't happen in a vim buffer, or the outer shell.
$SHELL is /bin/bash.
$TERM is xterm both inside and outside vim.
The issue also happen with home/end with `:term python` (of course Python is Python 3)
The issue doesn't happen with vim:term inside termite, only in xterm.
Although manually calling `TERM=xterm-termite vim --clean` in xterm doesn't work either. (I know this is incorrect)

Offline

#5 2021-03-15 14:59:19

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 72,033

Re: [SOLVED] Home/End in `:term` inside vim inside xterm output 7/1

Interestingly yes, doesn't happen in urxvt either - seems really limited to xterm.
Despite explicit escape code binding in zsh and "cat" indeed shows that no escape codes are generated.

Edit: vim has a ton of "xterm" tests in its code and symlinking xterm to yterm and running that "yterm -tn rxvt-unicode-256color" gets you a terminal w/ the expected rxvt-unicode-256color (terminfo needs to exist on your system) but the :term launched by vim manages to end in xterm-256color…

Last edited by seth (2021-03-15 15:41:45)

Offline

#6 2021-03-16 13:50:59

k395
Member
Registered: 2020-01-29
Posts: 37

Re: [SOLVED] Home/End in `:term` inside vim inside xterm output 7/1

It appears that the cause is that  <xHome> is set to `^[O*H` instead of `^[OH` by default.

I still can't understand why it's the case
(while `<xHome>-xterm` documentation says that the default is `^[OH`)
and why Vim can still recognize the keypress.

It's really weird, because in termite the escape sequence is exactly the same and vim can recognize it without problem.

Update: Not really solved, but this is a workaround.

tmap <kHome> <Home>

(also do the map in other modes if you want to -- `map` and `map!` should cover most useful ones, and for `<End>` `<PageUp>` `<PageDown>`)

My keyboard don't even have the NumLock key...

Last edited by k395 (2022-01-29 08:11:04)

Offline

Board footer

Powered by FluxBB