7

This question already has an answer here:

setcolors.vim of vim's Wikia defines these keybindings:

"   F8                next scheme
"   Shift-F8          previous scheme
"   Alt-F8            random scheme

but when I use Shift+F8 (the other two work fine) vim just changes the case of the 2 letters on and exactly after the cursor. Running :map I see

  <S-F8>      * :call NextColor(-1)<CR>

so why am I getting this change-2-character-case behavior?

Second, I tried to unmap Shift-F8 by running :unmap ^[[32~ obtaining ^[[32~ by Ctrl+v and then Shift+F8, but this did not work.

So how do get the desired behavior, getting the previous color scheme with Shift+F8?

Update + PS: I use vim in urxvt/tmux.

I created another user account in my machine (linux), logged in and run vim on a virtual terminal (Ctrl + Alt + F2) and I get the same behavior with Shift+F8, and clearly, I have no vim plugins there, and no tmux either(!).

Next, in my account instead of running urxvt+tmux+vim I run xterm+vim, and Shift+F8 works just fine! Then I run xterm+tmux+vim but now Shift+F8 changes 4 characters instead of 2!

So it should be a terminal/tmux related issue and not a vim issue. I have not managed to find what causes the problem though and how to fix it though...

Update after comments

echo $TERM is xterm-256color in:

  • xterm,
  • urxvt,
  • tmux inside urxvt or xterm,
  • vim, running :!echo $TERM inside every one of the above.

Ctrl+v and immediately after Shift+F8 produces:

  • ^[[19;2~ in xterm or invim inside xterm
  • ^[[34~ in tmux inside xterm or in vim inside tmux inside xterm, and
  • ^[[32~ in urxvt or in tmux inside urxvt or in vim inside tmux or in vim inside tmux inside urxvt.

In vim, :version shows +terminfo and there is clearly no +termcap.

The output of :set ttybuiltin termcap differs slightly between:

marked as duplicate by Rich, peterh says reinstate Monica, Martin Tournoij Sep 2 '18 at 17:16

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    A good way to test this is to compare vim against gvim. I believe it has something to do with urxvt, I can replicate the exact same behaviour in my urxvt terminal but it does not happen at all in gvim. – grochmal Jun 26 '16 at 22:20
  • 1
    This is a typical termcap / terminfo problem. Shift-F8 is recognized as such by Vim only if the code produced by the keyboard in the current terminal agrees to the termcap / terminfo entry for Shift-F8 for the current TERM. So, what is the output of echo $TERM in your tmux? What is the output if you press Ctrl+V Shift+F8 in the same tmux? – Sato Katsura Jun 27 '16 at 4:16
  • 1
    Now, what is the output of infocmp -1 xterm | fgrep -w kf20 (in a terminal)? – Sato Katsura Jun 27 '16 at 15:18
  • 1
    ^[[19;2~ is the same as \E[19;2~, so Shift-F8 is only going to work in xterm. Now, there are two ways to fix this: (1) fix TERM in tmux and urxvt, or (2) fix it only in Vim. For (1) see here for tmux (choose the screen-256color way), and complain upstream for urxvt. For (2) you can just add if &term == 'xterm-256color' | map <Esc>[19;2~ <s-F8> | endif to your vimrc. – Sato Katsura Jun 27 '16 at 15:39
  • 2
    This question now has an answer here: Some function keys switch cases of letters under and after the cursor – Rich Sep 1 '18 at 22:29

Browse other questions tagged or ask your own question.