I was concerned about the terminal scroll inside screen, besides I have configured altscreen on it only affects some programs, not taking any effect when switching between windows.

I know printf '\ec' clear the terminal better than the Ctrl+L or common clear command, so that I have decided to apply this.

The default termcap for cl entry is \E[H\E[J which is the same as ho (\E[H) followed by cd (\E[J) you can get this values if you echo $TERMCAP inside a screen session.

I wondered if changing cl to \Ec would cause the effect I expect, and it does, cheers! But unfortunately it caused a huge side effect: arrow keys stopped working inside vim.

I am still able to navigate using H, J, K and L keys, so that I see no reason for not working with arrow keys.

I want to avoid to change .vimrc as it is caused by screen, and I can run vim inside an ssh session so I would have to change the .vimrc of all machines.

Here is my current .screenrc:

vbell off
startup_message off
altscreen on
termcapinfo xterm* ti@:te@:cl=\Ec
#termcapinfo xterm* xn:hs@:cd=\E[J:ho=\E[H

I have been trying some variants, with and without ti and so on, but the problem seen to be cl itself, if its value is \E[H\E[J it works, otherwise don't.

To reproduce the problem write the file $HOME/.screenrc with the content above and start a session with for instance screen -ADRS profile, and then try to vim .screenrc, you can see you won't be able to navigate using key arrows on keyboard, only HJKL keys.

Screen version 4.03.01 (GNU) 28-Jun-15
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Nov 24 2016 16:44:48)

Is it possible to have the same behaviour as clearing with \Ec and keep the vim working?

Note1: as @schily claimed, it isn't necessarily a termcap problem, but maybe a terminfo, but either way I'm using termcapinfo statement on my .screenrc that according the manual apply the tweak rule for both termcap and terminfo, I'm not an expert on termcap/info, I just want to solve this.
Note2: running vim with :set term=linux make it works, but as I have stated before I would like to avoid changing .vimrc.
Note3: it affects less as well, and probably others, one more enforcement regarding being a screen problem.
Note4: I filed a bug: https://savannah.gnu.org/bugs/?54317

  • 2
    Why do you believe that vim is using termcap? – schily Jul 15 '18 at 13:53
  • @schily I'm not making any assumption, I'm just reporting the facts, have you tried to reproduce the problem? – Tiago Pimenta Jul 15 '18 at 20:45
  • Well vim links to libterminfo, so it will not be affected from termcap changes. There are currently few editors that use termcap even though termcap is much faster than terminfo. – schily Jul 15 '18 at 21:28
  • As I read from manual, termcapinfo on screenrc is the same as termcap and terminfo tweak both, so, where I write termcap you can assume I'm refering to both termcap and terminfo. – Tiago Pimenta Jul 15 '18 at 21:31
  • libterminfo emulates the interfaces from libtermcap, but it never reads the termcap data base. – schily Jul 15 '18 at 21:36

Your Answer

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

Browse other questions tagged or ask your own question.