4

I always thought Vim restored the previous contents of the screen upon closing. This allows me to remember what commands I was typing previously and what I wanted to do next.

Recently I've been using Debian 6 and Ubuntu (CLIs only) in a VM for a development project and I've been extremely annoyed with how Vim is operating. After I close the file its contents stay on the screen making me second guess whether I'm still in Vim or not, and having to use history to find out what I typed previously.

I've been unable to find any solution. Using tput smcup and rmcup for instance does absolutely nothing.

peu ping
  • 145

3 Answers3

3

Edit your .screenrc file and add the command "altscreen on".

Reference from the manual:

— Command: altscreen state

    (none)
    If set to on, "alternate screen" support is enabled in virtual 
    terminals, just like in xterm. Initial setting is ‘off’. 
0

Try enabling the alternate screen on your terminal emulator. In xterm, Ctrl+Middle Click will give you a menu, then select "Enable Alternate Menu Switching".
If that works, you can edit your .Xresources to contain: xterm*titeInhibit: false and then type $ xrdb -merge < ~/.Xresource. I haven't tested that config though.

0

Under VIM help for restorescreen:

                        'restorescreen' 'rs' 'norestorescreen' 'nors'
'restorescreen' 'rs'    boolean (default on)
                        global
                        {not in Vi}  {only in Windows 95/NT console version}
        When set, the screen contents is restored when exiting Vim.  This also
        happens when executing external commands.

        For non-Windows Vim: You can set or reset the 't_ti' and 't_te'
        options in your .vimrc.  To disable restoring:
                set t_ti= t_te=
        To enable restoring (for an xterm):
                set t_ti=^[7^[[r^[[?47h t_te=^[[?47l^[8
        (Where ^[ is an <Esc>, type CTRL-V <Esc> to insert it)

You may have a

set norestorescreen

-or-

set restorescreen!

in your .vimrc somewhere. (or one of your additional scripts). The default is to restore the previous screen's contents.

Remember to look for the short versions (nors / rs!) if you don't find the whole option name.

lornix
  • 11,909