When I lose power, I have a lot of maybe-useful swap files (4
vim instances running now, 103 swap files currently in
~/.cache/vim/swap). I am fine with manual recovery of swapfiles with changes - I'd just like a way to either:
- delete all lock-only swapfiles post-reboot or other times I know there are no running
- minimize the number of lock-only swapfiles to 1 per open instance of
I opened an issue on Github to see if
vim could manage 2 without any plugins, etc, but unfortunately it was not deemed worthy of support hours.
I request a solution to either 1 or 2 which:
- is easy to remember - short, small, easy to copy-paste between computers
- and is not instructions for the computer to download or call a special dependency - ie, no
vimplugins, Java programs, etc. The entire solution needs to be short enough to match the above criterion. So, ie, 5 lines of
vimscript/etc would be great.
- Haven't found a
vimcommand-line flag to tell me if a swapfile is only a lockfile instead of a recovery file
- Haven't found a
vimscriptinstruction to store lock and recovery files separately.
- Have read the source to 3-4 different vimscript plugins - one removes
set hiddenon buffer switch, another diffs swap files, another deletes swap files without regard for if they're lock files, etc. None (so far) are simple enough to be easily portable.
- GitHub issue
rm ~/.cache/vim/swap/*- destroys recovery files along with the lock files
Have not yet tried:
- reading the swap file format to see if there's something I can hook to w/eg
- installing/testing various
vimscriptplugins - not very portable
- setting read-only mode by default, then setting it again when I save a buffer. I'm looking for something I do at most once per boot, not on every file access - if every file access that's why we have software.
- as the above, but w/o
set hiddenby default