1

Sometimes I browse around the directory of the current buffer by using :Ex. On one of my development machines, this results in a .swp file being created in every directory I visit.

I've checked the directory variable other machines where this doesn't seem to be the issue, and they match (directory=.,~/tmp,/var/tmp,/tmp).

I understand that .filename.swp files are useful for recovery and I would not like to disable swap files globally. The .filename.swp files are correctly cleaned up when buffers are closed.

I would be OK with this behavior for directories if the files were cleaned afterwords, but they linger... eventually I run find -name ".swp" -delete to clean them up.

:version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan  2 2014 19:39:32)
2

This is probably a netrw bug. You might be able to work around by creating a file ~/.vim/after/ftplugin/netrw.vim (create non-existent directories) and put in there :set noswapfile

| improve this answer | |
  • Would this disable swapfiles for files being edited? – Pete Nov 18 '16 at 14:42
  • no, only for netrw buffers. – Christian Brabandt Nov 19 '16 at 16:23
0

Netrw normally sets noswf, which is a buffer-local option, for its own buffers. However, if you have let g:netrw_use_noswf= 0 in your .vimrc, then netrw won't set noswf, which may cause your problem. What does :verbose set swf? show?

| improve this answer | |
  • I went with Christian Brabandt's solution, so it shows "noswapfile last set from ~/.vim/after/ftplugin/netrw.vim" – Pete Dec 29 '16 at 22:43
  • if I remove the :set noswapfile, :verbose set swf? results in " swapfile". – Pete Dec 29 '16 at 22:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.