Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Vim sometimes create .swp files?

Tags:

vim

Sometimes Vim creates a .swp file when I edit something, but not always. Why is that, and what causes Vim to create .swp files? Is it bad to disable them in .vimrc?

like image 954
Robin Avatar asked Jun 04 '15 17:06

Robin


People also ask

How do I delete a SWP file in Vim?

Make a note of the swap file name (e.g., . after. c. swp ), exit vim, type rm .

Where does vim store swap files?

While editing a file, you can see which swap file is being used by entering :sw . The location of this file is set with directory option. The default value is .,~/tmp,/var/tmp,/tmp . This means Vim will try to save this file in the order of . , and then ~/tmp , and then /var/tmp , and finally /tmp .

What is .SWO and .SWP file?

The . swp is created when a file is opened in the editor. The . swo is created if the file is edited and the . swp already exists.


1 Answers

Vim creates .swp files for recovery. In case you fail to save, vim will be able to recover (at least some of) the file.

The merits of disabling them depends on what you do. If you use vim for anything that has a build, you probably save your sources all the time (how much time goes by between your coding stuff and compiling, building, and running a ut? Probably not hours). I hate the swps because they always require me to tell the version control system to ignore them.

like image 72
Ami Tavory Avatar answered Oct 19 '22 23:10

Ami Tavory