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?
Make a note of the swap file name (e.g., . after. c. swp ), exit vim, type rm .
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 .
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With