13

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?

dan
  • 43,914
  • 47
  • 153
  • 254
  • 2
    I kinda like having that output around. So many times I'd open something in vim to quickly check, close it and then wonder what was it that I just saw. With GNU Screen, I just enter copy mode `C-a [`, `j`/`k` to navigate and find it. – Jeffrey Jose Sep 17 '10 at 23:08

2 Answers2

29

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

ZoogieZork
  • 11,215
  • 5
  • 45
  • 42
3

This is caused by your termcap for screen being incomplete. (This seems to be a really common problem.) Vim doesn't know the sequence for restoring the screen, so it just leaves it like it was.

You can work around this problem by setting vim's term option (or the TERM environment variable before you start vim) to a terminal that's "screen compatible", like xterm. eg:

TERM=xterm vim

or (in vim):

:set term=xterm

You can set the t_ti and t_te options in vim to the right codes. See :help xterm-screens in vim for more details.

Laurence Gonsalves
  • 137,896
  • 35
  • 246
  • 299