I just started using buffers in Vim and I couldn't figure out how to list recent closed buffers. Is there a simple way (like :ls
) to list those? Are they actually stored by Vim?
Maybe I'm misusing buffers, but what I want to do is to glance at recent closed buffers and then reopen (:e
) one of those (of which at that moment I don't remember the (file)name).
I searched windows.txt
(from :help buffers
) for terms like history
, closed buffer
, buffer closed
, but none of them got me closer to doing what I want.
Edit: I tried :oldfiles
(as D. Ben Knoble suggested) but that doesn't seem to work as I'd expect. When I'm viewing one file (buffer) A.file
and open another one B.file
(using NERDTree) and just after that I close B.file
, then :oldfiles
doesn't show B.file
on the list.
:oldfiles
—depends on what you mean by “closed”:h :oldfiles
...it explains exactly how it works. You can force it to behave a bit closer to expectations by jumping through some hacks...cough...hoops.:oldfiles
does is based on theviminfo
file, but I'm not sure how would I accomplish what I asked. Are you suggesting putting each new buffer filename insideviminfo
automatically with some script? I guess it's possible to use some hook whenever a new buffer is created, but I have no idea how to do any of that.buffers
? As you open new files they get added to the bottom of the list (most recent). You can see buffers no longer "visible" aka hidden":help buffers
has a legend. This was the answer for me when I was looking to reopen the last file I had open after I had accidentally opened another file over my active window.