Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Home and End keys not working in Tmux and TERM=screen-256color #8032

Closed
frol opened this issue Feb 20, 2018 · 6 comments
Closed

Home and End keys not working in Tmux and TERM=screen-256color #8032

frol opened this issue Feb 20, 2018 · 6 comments
Labels

Comments

@frol
Copy link

@frol frol commented Feb 20, 2018

  • nvim --version: v0.2.2
  • Vim (version: 8.0.1476) behaves as expected (in contrast to neovim)
  • Operating system/version: Arch Linux (Gnome 3)
  • Terminal name/version: tmux 2.6 in Gnome Terminal 3.26.2
  • $TERM: screen-256color

Steps to reproduce using nvim -u NORC

nvim -u NORC
i1234<ESC><HOME>

Actual behaviour

<HOME> (and <END>) doesn't put the cursor to the beginning of the line while <CTRL>+<HOME> works fine (moves the cursor to the beginning of the file).

Expected behaviour

<HOME> should put the cursor to the beginning of the line.

Extra notes

I have read the related issues (#4308 and #6014) and FAQ on this matter, but given that I already have TERM=screen-256color, they didn't help.

In the same session, vim works as expected.

I have tried setting TERM to xterm-256color, xterm, and screen and it turned out that screen value fixes the issue with <HOME> / <END> buttons, but it doesn't seem correct to me, so I decided to report it.

I want to also note that everything used to work just fine up until a few days ago, and I haven't touched any configs and I don't recall updates either to neovim nor tmux, but the fact that everything but neovim works just fine forced me to write this issue just in case if I am not alone.

Any idea on how I can inspect the issue?

@mhinz

This comment has been minimized.

Copy link
Member

@mhinz mhinz commented Feb 20, 2018

Does TERM=tmux-256color make a difference?

@frol

This comment has been minimized.

Copy link
Author

@frol frol commented Feb 20, 2018

@mhinz TERM=tmux-256color doesn't help, but TERM=tmux does the trick just like TERM=screen.

@mhinz

This comment has been minimized.

Copy link
Member

@mhinz mhinz commented Feb 20, 2018

The next release will automatically use a built-in terminfo entry if tmux is detected but $TERM is not tmux-256color. That should avoid such issues.

Tmux used to use screen and screen-256color in the past because it was widely available. But it was still meant for screen. Modern ncurses versions ship with tmux and tmux-256color.

@justinmk justinmk added the duplicate label Feb 20, 2018
@justinmk

This comment has been minimized.

Copy link
Member

@justinmk justinmk commented Feb 20, 2018

I want to also note that everything used to work just fine up until a few days ago

#8027

@justinmk justinmk closed this Feb 20, 2018
@justinmk justinmk added the tui label Feb 20, 2018
@frol

This comment has been minimized.

Copy link
Author

@frol frol commented Feb 20, 2018

@justinmk Oh, thank you! Sorry for the duplicate.

I confirm that unibilium 2.0 fixes the issue (installed from the community-testing Arch repo)

gjeusel added a commit to gjeusel/waxCraft that referenced this issue Aug 12, 2018
@cemeyer

This comment has been minimized.

Copy link

@cemeyer cemeyer commented Dec 10, 2019

Hm, the autodetection seems kind of broken in GNU screen:

nvim: 0.4.2
unibilium: 2.0.0
term: terminology 1.4.1
screen: 4.7.0

.screenrc: term screen-256color

Outside screen: TERM is xterm, HOME/END keys work in nvim.

Inside screen: TERM is screen-256color, HOME/END keys do not work. It seems nvim ignores TERM? From an example in 7798,

nvim -V3log
:q

Shows:

--- Terminal info --- {{{
&term: builtin_xterm
Description: xterm with 256 colors
Aliases: xterm-256color
...

With the wrong (xterm) codes for key_home and key_end. infocmp in the same screen session shows the correct kend and khome sequences.

Why does nvim think it knows better than my (correct) $TERM? Here's the wrinkle: XTERM_256_COLORS=1 (set by terminology, I guess) is inherited, for shells inside screen. And apparently that overrides TERM for nvim's purposes.

unset XTERM_256_COLORS ; nvim -V3log

--- Terminal info --- {{{
&term: builtin_screen
Description: GNU Screen with 256 colors
Aliases: screen-256color

So... I can hack around this with unsetenv XTERM_256_COLORS in .screenrc. But I wonder if ignoring TERM if XTERM_256_COLORS is set is really the right thing to do here?

Edit: and even when it correctly infers builtin_screen, Home/End keys are still broken. Ugh.

&term: builtin_screen
...
  key_home                  khome      = <Esc>[1~
  key_end                   kend       = <Esc>[4~
$ infocmp | grep ...
        kdch1=\E[3~, kend=\E[4~, kf1=\EOP, kf10=\E[21~,
        khome=\E[1~, kich1=\E[2~, kmous=\E[M, knp=\E[6~, kpp=\E[5~,
$ showkey --scancodes
...
<ESC>[1~<ESC>[4~     # Pressed Home, then End

So everything seems to line up, but nvim still isn't handling home/end correctly?

Edit2: Ah, FreeBSD is still on the dead mauke unibilium fork. I have filed https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=242560 . Hopefully that addresses the issue I'm seeing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.