Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
add comment

3 Answers 3

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.

share|improve this answer
    
No no X, no xterm. :\ –  peu ping Jun 23 '12 at 14:57
    
@peuping Sorry I should have realised. It seems that the virtual console doesn't support the alternate screen (I can't find an authoritative link). You could try GNU screen or tmux terminal multiplexers. For example in a screen session you could try $ screen vim which would start your vim session in a new pseudo-terminal and leave your command line untouched. –  donothingsuccessfully Jun 23 '12 at 15:55
add comment

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.

share|improve this answer
add comment

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’. 
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.