Go to back directory browsing after opening file in vim

Solution 1:

You can go back to the last buffer using :b#.

If you just opened a file, then it will bring you just back to the directory browsing.

Update: Since this answer happened to be accept as the correct answer and is thus on the top, I'd like to summarize a bit the answers, including the one by @romainl that imho is the correct one.

  • :Rex[plore]: Return to Explorer (by @romainl) vimdoc.sourceforge
  • :Explorer: opens the Explorer, same as :E (if not other command starting with E is defined (see stackoverflow), or as :Ex (see vim.wikia) (by @drug_user841417).
  • :b#: goes back to the "previously edited buffers". See vim.wikia
  • :e# or Ctrl-6 (or Ctrl-^): goes back to the "previously edited file" (by @aman-jain). See vim.wikia
  • Ctrl-O: jump back to the previous (older) location, not necessarily a buffer (by @Peyman). See vim.wikia

Solution 2:

You can use Ctrl-O to go back to the previous buffer.

Solution 3:

The proper command for returning to the netrw listing is :Rex[plore]. You can run it even after you have jumped to and from dozens of files.

Solution 4:

:Ex will take you back (and show you what you edited and didn't save).