VIM: Disable Swap

6

How does one disable swap files for VIM via .vimrc?

Jeremy L

Posted 2009-10-28T13:03:11.037

Reputation: 2 587

Answers

11

set nobackup
set nowritebackup
set noswapfile

ennuikiller

Posted 2009-10-28T13:03:11.037

Reputation: 980

3Backup files can be useful if you need the original quickly. Also keep in mind that by turning off nowritebackup you risk destroying the file in case of an IO error. – John T – 2009-10-28T14:33:41.203

4i'd guess that disabling either backup or swapfile is reasonable, but not both. i disable the backups but the swapfile's saved my derriere a few times. – quack quixote – 2009-10-28T15:40:49.070

2I really wouldn't be concerned about an IO error; I should like to think if it occurred, recovering my changes to the file are the least of my worries. – Jeremy L – 2009-10-28T17:55:16.350

6

Throw this into your .vimrc:

set noswapfile

John T

Posted 2009-10-28T13:03:11.037

Reputation: 149 037

5

I would not disable swap files completely because they are used for recovery if vim crashes.

Instead, put them into a temp folder so that they are not scattered all over:

if has("win32")
   set directory=c:\\tmp,c:\\temp
elseif has("unix")
   set directory=/tmp
endif

Kevin Panko

Posted 2009-10-28T13:03:11.037

Reputation: 6 339

3

start vim with the "-n" argument:

vim -n <file>

Kevin M

Posted 2009-10-28T13:03:11.037

Reputation: 2 396