If the backup parameter is set, vim updates the backup file every time we write the file with :w . And every time he creates a file that is not hidden, even if you forcibly hidden it earlier! Therefore, we need to do something every time we write a buffer to a file.
You can do it on windows. In the _vimrc file (usually in 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 ensures that the backup file will be hidden with each write to the file from the buffer. Why every time? Cos vim creates a non-hidden file with every recording!
But you have to live with a blinking black window (the command window where we execute the attrib ) every time you save the file, but you are in pain :)
On linux / unix systems you can add this to your .vimrc
autocmd BufWritePost,FileWritePost * silent ! mv <afile>~ .<afile>
Hope this helps everyone who is trying to find how to hide vim backup files.
source share