Deleting Orphaned Vim Swap Files

Created: 2020-01-27, Last Updated: 2023-02-04

My laptop has a tendency to reboot on it's own, randomly. While this is annoying I haven't had the time to diagnose what's going on. However, the annoying part about this is that if I have vim open it will orphan any swap files I have for open files. To get around finding and deleting each one manually I decided to leverage the find command like this

find . -name '*.sw*'

That will show you any swap files that are out there.

Now that I knew which files were present I was then thinking of piping this to rm so I didn't have to copy and paste each file. However, I learned that find has an option to delete the files it has. -delete. This means I can simply do

find . -name '*.sw*' -delete

With that the file are gone.

Back