What you call a directory listing is actually a special buffer with type netrw
. It is created by a plugin also called netrw
. Your issue probably stems from the fact that netrw
(with the default listing) creates several hidden buffers, one for each directory listing you pass through, i.e. every time you change directory a new hidden buffer is created.
But your question is about how to manage the directory listing. netrw
can be opened from within Vimin different ways, and, probably, at least one of these ways will prove more useful to your workflow. You can open netrw
with:
:Explore
: The default,
:Hexplore
: In a horizontal split,
:Lexlplore
: Left split that can be used as a toggle,
:Sexplore
: Horizontal split using the current's file CWD,
:Vexplore
: As Sexplore
but in a vertical split.
:Texplore
: In a new tab.
And there is also :Rexplore
which returns the current window to a previous buffer that is not a netrw
buffer. In other words, you can use :Rex
to exit from the directory listing into the closest regular buffer.
Yet, I'd definitely suggest to you to explore (pun intended) the other options of running the netrw
listing. Personally I find:
:22Lexplore
To be extremely useful.
Extra note: netrw
has several global variables that can be set inside your vimrc
to customize how the listing looks and behaves. See :help netrw
for an extensive list.