VIM^s#04 Disable backup and swap files

As I am editing files using Vim, I get to see that there are couple of backup files (with extension, *.ext~) and swap files (with extension, *.swp) being created.

Even though these files are pretty handy for backup and recovery in Vim, sometimes they tend to become quite annoying, especially in my case, where I was using git and these files are always listed in the ‘git status’. One solution to avoid these files showing up as part of your original changes is to include the file extensions in the .gitignore file.

But there is another, straight forward way to avoid them from coming in between your work.

1. disable the backup option by adding the following lines to the .vimrc file

set nobackup
set nowritebackup
set noswapfile

2. Another way is direct all these file creation to a centralized location. (somewhere outside your project repository scope by adding the following lines to the .vimrc file

set backupdir =~/temp/vim,.
set directory=~/temp/vim,.

For more details checkout the following link:


About this entry