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?

Community
  • 1
  • 1

2 Answers2

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
Michael Berkowski
  • 267,341
  • 46
  • 444
  • 390
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:
Michael Anderson
  • 70,661
  • 7
  • 134
  • 187