This is related to, but not solved by the question “How can I recover the original file from a .swp file?”.
I had two newly-created files
b.txt open in buffers. The active buffer was
b.txt, and I accidentally deleted
a.txt, and then switched to the buffer
a.txt. Unfortunately, I also have
set autoread and
set autowrite, so by reloading the buffer I emptied it.
I tried simply undoing the deletion in Vim by pressing u, but to no avail. Is there a way to recover the content of the deleted file from
.a.txt.swp? The solution to the linked question doesn’t work here, presumably because of
autowrite: the file is not restored.
In case it’s important, I also have
set undofile. Also, since the file was newly created in this Vim session, the
.swp file should, in principle, have contained the complete set of edits made to the file.