Debugging Vim: Read-Only Errors and `fzf.vim` Freezes
Vim is reliable, but a bad shutdown can leave behind swap files that confuse it. I hit two symptoms in one go: Vim refused to save a Python file (“readonly” warnings) and fzf.vim froze as soon as I opened a match from Rg. The fixes were the same and simple.
Symptom 1: Vim insists the file is read-only
Every save showed:
E45: 'readonly' option is set (add ! to override)
But the filesystem permissions were fine:
-rw-r--r-- 1 myself staff 46560 12 Aug 14:54 my_python_code.py
What was really happening
Vim leaves a swap file per open buffer so it can recover after a crash. I had three variants lingering:
-rw-r--r-- 1 myself staff 4096 12 Aug 15:01 .my_python_code.py.swn
-rw-r--r-- 1 myself staff 4096 12 Aug 14:57 .my_python_code.py.swo
-rw-r--r-- 1 myself staff 131072 7 Aug 15:55 .my_python_code.py.swp
Multiple swap files usually mean an unclean exit or another Vim instance still has the buffer open. In my case they were leftovers.
Fix
Delete the stale swap files and reopen:
rm .my_python_code.py.swp .my_python_code.swo .my_python_code.py.swn
After that, saving worked normally—no :w! required.
Takeaway: if Vim claims a file is read-only but ls -l shows write access, check for .sw? files alongside it.
Symptom 2: fzf.vim freezes after selecting a file
Using Rg to jump to a match, the terminal froze after hitting Enter. No traceback—just a hung screen.
Fix (the same one)
Clearing the same swap files fixed the freeze. fzf.vim was tripping over the conflicted buffer state.
Takeaway: unexplained plugin hangs—especially when opening files—often trace back to swap conflicts.
Quick checklist
- Check for a running Vim that still owns the file (
ps ux | grep vim). - Look for swap files next to the file (
ls -a | grep '\.sw[pno]$'). - Remove stale ones only if you’re sure no other Vim needs them.
- If you want Vim to ask before using a swap, keep
set swapfileand heed the prompt; to avoid surprises on NFS/temp dirs, considerset directory^=$HOME/.vim/swap//.
Methodical checks beat guesswork. In this case, a tidy-up of stale swap files restored both saving and fzf.vim navigation.