When using vim or less in gnu screen, quitting vim or less leaves a lingering imprint

gnu-screen, unix

Solution

screen's `altscreen` (alternate screen) feature is turned off by default.

Add this to your `.screenrc`:

altscreen on

See: http://www.gnu.org/software/screen/manual/screen.html#Redisplay

Problem

On my new Ubuntu system, I start a screen session and edit a file in vim or view it in less. After I quit, the screen doesn't redraw itself, but simply scrolls up to show a command line under all the stuff I was just viewing in vim or less. How can I change this so that quitting vim will return me to the screen the way it was before I invoked vim?

Original source