3

I normally use Ctrl+PageUp and Ctrl+PageDown to switch tabs in Vim. But when running Vim inside GNU screen, they don't switch tabs and instead have the effect of switching case.

I am running the following bindings in my .screenrc:

bindkey "^[[1;5D" prev
bindkey "^[[1;5C" next

These allow me to move between screen tabs with Ctrl+ and Ctrl+.

But disabling those bindings doesn't solve my problem so I don't think they are the culprit.

I am assuming there is some interaction between my terminal emulator, screen, and Vim that I don't understand.

Edit: I have found via this answer that starting vim with the TERM environment variable set (overridden) to xterm is a viable workaround, like this:

TERM=xterm vim

But I think the question still stands as I want to know why this is necessary.

2

Normally when you run screen it does some initialization which (depending on the actual terminal) may change the escape sequences sent by the various keypad-keys.

For instance, I can see that it initializes xterm:

  • application cursor keys
  • application keypad

In application mode, xterm (and other terminals) change the way the unmodified special keys send escape sequences, using a different prefix (escape[ versus escapeO). For modified keys (such as controlPageUp), xterm does not change its scheme. But the terminal you are using may do this.

Since neither screen nor vim pays any attention to the terminal description for these modified keys, they would not see that the terminal description differs when running screen. But you can check to see how running screen changes the actual strings sent by these keys, and adjust your .screenrc to reflect that.

You can see the actual strings using

  • cat -v (on most systems), or
  • prefixing special keys with controlV

Further reading:

  • How should I check to see the actual strings sent by these keys? – jl6 Feb 27 '16 at 20:33

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.