GNU screen clearing on vim,less,etc. exit

The answer lies in the terminal capabilities of both the "real" terminal that you are using and the terminal that is presented to applications via screen. Applications performing their terminal I/O via screen see a terminal of type screen. Your "real" terminal could be anything from xterm to vt100. (Use printenv TERM or equivalent to find out.)

TUI applcations like vim and less tailor their behaviour to whatever the terminal that they find themselves talking to is capable of. This answer is far too short for a detailed exposition of the mechanics of the terminfo mechanism, or even for the mechanics of how programs like vim and less make use of it. There are whole books on this stuff. A very brief précis is that your "real" terminal is advertising a capability that the screen terminal is not.

Plus, of course, this has already been answered on SuperUser at length, here and here and here.


put altscreen on in ~/.screenrc or Control+a:altscreen+Return