Currently when I am not using screen utility, I am able to see the VIM content wiped out of the display when I quit VIM. However when I am using GNU Screen utility and opening a file in one of the screen window and closing it, I can see the trailing file content on the display. It’s not wiping out the file content from the display the way it does when I am not using GNU Screen.

I found the below post where it has been discussed without GNU Screen.

How to set the bash display to not show the vim text after exit?

In my case, in both the scenario [with and without GNU Screen] the Terminal Type is “xterm”. But the behavior is different when I close a VIM file.

Kindly help.

  • What if you set TERM to screen-bce or screen while running screen? – muru Nov 9 '15 at 8:24
  • @muru: I tried and it didn't helped. But as suggested by Thomas/cas, adding altscreen command to the screenrc did the magic. Thank for your time and suggestion. – Satish Nov 9 '15 at 9:38
  • Bash is not a terminal; it does not provide a display; and you would get the exact same behavior if you had any other shell (ksh, zsh, etc). One might consider removing references to it from the title and question. – Charles Duffy Nov 9 '15 at 17:07

GNU screen supports the xterm alternate-screen feature using the altscreen setting in your .screenrc file. According to the manual:

— Command: altscreen state
If set to on, "alternate screen" support is enabled in virtual terminals, just like in xterm. Initial setting is ‘off’.

A quick check shows that screen is actually simulating the feature, because it clears and/or restores the screen contents itself without sending the control sequence used by xterm. The screen feature works whether or not the actual terminal (or its terminal description) supports the alternate screen feature. You can test this by setting TERM to "vt100" before running screen.

You can read more about the alternate screen feature in the xterm FAQ Why doesn't the screen clear when running vi?

  • Yes. It worked. I added altscreen to my screenrc file and I got what I wanted. Thanks for the quick reply. – Satish Nov 9 '15 at 9:32

Add altscreen on to your ~/.screenrc and restart your screen session.

From man screen

altscreen on|off

If set to on, "alternate screen" support is enabled in virtual terminals, just like in xterm. Initial setting is `off'.

  • Thank for the reply. Even Thomas suggested the same and it works. – Satish Nov 9 '15 at 9:32

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.