When I run vim in a win32 console window, after I exit I end up with a bunch of junk on the screen - old command output, etc, because cmd doesn't clear line contents when scrolling down. I've included an example below:


Is there a way to make vim clear the whole screen buffer (not just the part that is visible), either when starting it or on exit? Or to save the entire state (buffer contents, scroll position, and cursor position) and restore afterward?

1 Answer 1


On further investigation, the restorescreen option was being set incorrectly in my vimrc.

I had this code (I don't know where I got it):

if exists(&restorescreen)
    if has("win32")
        set restorescreen
        set norestorescreen
    set t_ti= t_te=

but exists(&restorescreen) actually evaluates to 0.

  • Try if &restorescreen if you want tho check if restorescreen is set, or if exists('&restorescreen') if you want to find out if there is an option named restorescreen (but that should always return 1, since said option is always compiled in).
    – lcd047
    Jun 19, 2015 at 15:12
  • I think it was meant to detect older vim versions from before the option existed - I just took it out, I've been trying to clean up the version condition stuff in my vimrc since everything I use is on at least 7.2 now.
    – Random832
    Jun 19, 2015 at 16:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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