Go to back directory browsing after opening file in vim

Vim

Vim Problem Overview


When I open a directory browsing in vim, I can open a file by moving the cursor to a file name and pressing Enter.

Now, is there any command to go back to the previous directory browsing?

If not, is there a way to open a file without closing the directory browsing mode?

Vim Solutions


Solution 1 - Vim

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.

Solution 2 - Vim

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

Solution 3 - Vim

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 - Vim

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

Solution 5 - Vim

I rely on Ctrl ^ to go back and forth b/w two buffers.

Solution 6 - Vim

I usually just use :E. It's easy to remember and gets you back to the directory listing of the file you had open.

Solution 7 - Vim

I'd like to use the Jump-motions shortcut keys to do any 'go back' or 'go forward' actions in Vim. It makes vim like a web browser.

You can search for Vim's help for more details.

> Vim :h jump-motions

So like as mentioned in other answers ctrl+O works cool, and hope vim's help-file let you learn more commands like ctrl+I .

Ctrl + I : Go Forward

Ctrl + O : Go Back

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMKoView Question on Stackoverflow
Solution 1 - VimezdazuzenaView Answer on Stackoverflow
Solution 2 - VimPeymanView Answer on Stackoverflow
Solution 3 - VimromainlView Answer on Stackoverflow
Solution 4 - Vimdrug_user841417View Answer on Stackoverflow
Solution 5 - VimAman JainView Answer on Stackoverflow
Solution 6 - VimNM PennypackerView Answer on Stackoverflow
Solution 7 - VimchenlolaView Answer on Stackoverflow