I have tmux set up with $TERM
being set to screen-256color
correctly. This works fine, and colours are set correctly, however it prevents me from sending HOME
and END
keys to the terminal, which are instead printed as F\n
and H\n
.
I should add that home appears to work in irssi, but not vim. Home seems to send (According to Ctrl+v <HOME>
), ^[OH
It may be worth adding that I am well aware of the ability to use ^
and $
to move to the start and end of the lines, however $
does not go to the end, rather the penultimate character, and I prefer to use HOME
and END
(as I can under other $TERM settings).
Can anyone explain why this is, and how I can fix it?
As a part-way fix, I set the vim keybindings to map a <Home>
and <End>
keypress to <Esc>OH
and <Esc>OF
. This isn't ideal, but works for the moment! See https://github.com/jvc26/dotfiles/blob/master/.vimrc for details.
Thanks!
The above mapping solution doesn't affect the command mode or visual mode. The following is a more ideal solution until either tmux or vim fixes the bug (put in your .vimrc):
"""""""""""""" " tmux fixes " """""""""""""" " Handle tmux $TERM quirks in vim if $TERM =~ '^screen-256color' map <Esc>OH <Home> map! <Esc>OH <Home> map <Esc>OF <End> map! <Esc>OF <End> endif
As a fix, I set the vim keybindings to map a <Home>
and <End>
keypress to <Esc>OH
and <Esc>OF
.
" Handle TERM quirks in vim if $TERM =~ '^screen-256color' set t_Co=256 nmap <Esc>OH <Home> imap <Esc>OH <Home> nmap <Esc>OF <End> imap <Esc>OF <End> endif
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With