Where does VIM (gvim/macvim) keep swap files for unsaved/unnamed buffers?
Start up vim and try:
:recover <filename>
If the file never had a name, then simply:
:recover
That's your best bet. For more about swap files and recovery, see:
:help usr_11
About the swap files, typically they're saved in the same directory as the file being edited, but with a . added the beginning to make it hidden and .swp at the end, but it's possible to move them elsewhere by something like:
:set directory=~/vimswap
or similar.
See:
:help swap
For all the details.
A vim swap file is not the same as the edited buffer, however, so be sure to read up there on what can be done for recovery.
EDIT: comments answering the question:
[…] It seems to look in your current working directory, ~/tmp, /var/tmp and /tmp for swap files and in my case I always have a current working directory set and that's where it got saved. – dsclementsen Oct 5 '10 at 1:42
also, be sure to check out the vim -r command line arg. This will print out all the swap files found and where they are. In addtion it will have a lot of extra information such as date/modified/username/etc... – Neg_EV Oct 5 '10 at 13:49
I work on Windows 10 and :recover
didn't find a swap file. vim -r
listed the swap file from the last edit session (also never saved) named _.swp. Recovering was possible with :recover _
.