3

I've got this password file, and when editing this in vim I want to make sure vim does not create a swap/backup file. How to set this?

I have seen this: How to prevent vim from creating (and leaving) temporary files?

But I do not want this for all files, just for a specific one. Is this possible?

2 Answers 2

3

If your file can contain comments you can set the nobackup and noswapfile by adding a modeline to the start or end of the file.

Something like this:

# vim: set nobackup noswapfile:
3

You could use autocmd to set nobackup for that filename or filenames matching a specific pattern/extension:

autocmd BufRead,BufNewFile passwordfilename set nobackup
autocmd BufRead,BufNewFile passwordfilename set noswapfile

Your Answer

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