I use a mix of buffers and split panes to manage my workflow. Sometimes, I (perhaps accidentally) open a directory listing instead of a file. My buffers may look like this then:

directory listing

At this point, I can :bnext or :bprevious to bounce between my buffers, but when in the directory listing I cannot :bp <BAR> as I would normally to close a buffer and I'm seemingly stuck with this awkward buffer that I can't remove. (I have these all nmaped in some capacity, FWIW)

Yes, my habits should get me to use CTRL+P more to search for files, but sometimes I find this method of file traversal useful, so understanding the proper way to manage these would be superb.

Thank you!

2 Answers 2


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:


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.

  • Ah, so fascinating and useful. Thank you for the detailed answer!
    – Bartek
    Commented Aug 11, 2016 at 0:12

When you end up in a netrw window you can do <C-^> (or <C-6>, depending on your keyboard layout) to switch to "the alternate file".

In this case, "the alternate file" is simply the buffer that was previously displayed in the current window.

<C-^> is a global command not related to netrw. See :help ctrl-^.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.