Vim tip: Open the last file you closed with :e#

I can’t believe I didn’t learn this earlier because now I do it all the time:

If you close a file, as I often do with :bd, to open the last file you closed, type e# in command mode:


The last closed file opens in your current window.

This is great for me because in my editing workflow, I have a story budget from one directory in one window, and I work on stories from a different directory in another. So my working directory is the story directory, and I would have to change it to reopen my budget file, which I often close when moving from one computer to another to do a Google Meet (aka Google Zoom) chat and not be too loud for everybody else in the house. (It’s 2020, and we’re quarantining.)

How do I get my files on multiple computers? I use Syncthing for that. And keeping the same file open simultaneously leads to conflicts and multiple file versions.

So being able to close a file in Vim with :bd and then reopen it with :e# is something I do every day.