Select a file or directory name and press Enter to open that file or directory. (For example :e /home/user displays the contents of that directory.) To return to the explorer window, press Ctrl-^ (usually Ctrl-6). You can also "edit" a directory to explore that directory.
You can type the partial file name and auto-complete with tab. You can start pressing tabs to traverse buffer list until you find the file you want to go to. You can go to previous buffer with # . This lets you to toggle back and forth previous file.
Type "gg" in command mode. This brings the cursor to the first line.
Since switching back to the previous file is something that tends to happen a lot, you don't have to move to the ex command line to do it. The vi command ^^ (the "control" key with the caret key) will do this for you. Using this command is the same as typing :e #.
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
You can use Ctrl-O to go back to the previous buffer.
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.
:Ex
will take you back (and show you what you edited and didn't save).
I rely on Ctrl ^ to go back and forth b/w two buffers.
I usually just use :E
. It's easy to remember and gets you back to the directory listing of the file you had open.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With