On Windows, I normally work with Total Commander, which can easily be configured to ignore these *.*~
and *~
completely. But occasionally when I switch to Windows Explorer, I get little bit confused with all that "unknown" files/.
Can I set up Vim so that for every backup it creates it will also set "hidden" attribute?
Or set up some nice workaround?
I know I can set up Vim to put these in other directory, but I'd like to avoid that, since IIUC, it could suffer from naming conflicts.
If the backup
option is set, vim
updates the backup file every time we write the file with :w
. And every time, it creates a file which is not hidden even though you had forcibly hidden it previously! So we need to do something everytime we write the buffer into file.
You can do this on windows. In your _vimrc
file ( generally found at C:\Program Files (x86)\Vim
), add this line
autocmd BufWritePost,FileWritePost * silent ! attrib +h <afile>~
Where,
attrib=Windows File attribute changinf command
<afile>= Name of the file being sourced
silent= Prevent an annoying command window from popping up and asking user to press a key
This will make sure that the backup file gets hidden with every write to file from buffer. Why every time? Cos vim
creates a non-hidden file at every write!
But you have to live with a flashing black window ( command window where we are running attrib
command ) every time you save your file, but worth the pain :)
On linux/unix systems you can add this in your .vimrc
autocmd BufWritePost,FileWritePost * silent ! mv <afile>~ .<afile>
Hope this helps all those trying to find how to hide vim backup files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With