Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to hide gvim's backup files under Windows XP?

EDIT: I think I have mistaken backup files as swap files. Actually I mean the files that end with ~. Sorry.

share|improve this question
up vote 3 down vote accepted

I wrote the answer below when the question was about Vim’s swap files. The same idea applies for Vim’s backup files with the option 'backupdir' instead of 'directory' (i.e. use a central directory for the backup files to keep them out of the way).

You could use a central location for the swap files. It would not “flip the hidden bit”, but it would effectively get them out of the way. See the documentation for 'directory'.

Place one of the following in your .vimrc/_vimrc (e.g. :e $HOME/.vimrc):

" Remove the current directory from the list of places that swap files might be created.
set directory-=.

" OR

" Explicit list of locations for swap files.
"   The double trailing slash makes the otherwise centralized swap files use
"   filenames that are based on the full pathname of the edited file
"   (this lets you edit (e.g.) README files from two different places without
"   getting colliding swap file names).
set directory=c:\\tmp//,c:\\temp//
share|improve this answer
Thanks a lot. I'm sorry for the mistake. – Jichao Sep 16 '10 at 5:59

One way to hide the backup files would be to put them in a separate directory. See

:help backupdir

Another way might be to use the BufWritePost autocommand to set the backup file's hidden attribute after it's written.

share|improve this answer

To prevent the backup file (the one with the ~ at the end) from being created, add the following to the end of the _vimrc file:

set nobackup

set nowritebackup

share|improve this answer

Hide or completely turn that off?

If the latter is OK, put to your .vimrc file line

set noswapfile

share|improve this answer

Somebody suggested an autocmd to set the filesystem's "hidden" attribute.

I wrote a plugin to do just that:

share|improve this answer

Your Answer


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.