5

Suppose that I'm editing a file, then I press :w to store it. And then I use :e. to navigate its containing folder in the netrw. Suppose its containing folder is ./A/B/. In netrw, I open a file with path ./D/E.

My question is when I enter into the file ./D/E, how can I return to ./D/ or ./A/B/?

I tried :b#, but only to return to the previous edited file, not to the netrw. I know that I can use :e. again to return to ./A/B/ since it's current path. Is there any way to return to ./D/, the containing folder of the currently being edited file?

Thanks

4
:E[xplore]

does the same thing as :e %:h, and is shorter to type.

If you look up :help :Explore, you can see that there are also variations to open the directory of the current file in a new tab or split instead of in the current window.

  • :E is no less convenient than <C-o>. But :E is easier to remember since I can group it together with :e, :sp., :vs. etc. – user3813057 Jul 1 '15 at 0:08
2

:e %:h navigates to the directory of the current file. See :help expand() for more info. Tim Pope's Vinegar plugin essentially binds - to this, and introduces a few small other conveniences.

You could also use <c-o> to navigate to the previous jump/file shown in the current window.

2

There are a lot of commands in netrw for directory navigation. Some that come to mind: :Rexplore (to return from a file to netrw); :help netrw-qb will inform you of netrw's history mechanism (u, U), :help g:netrw_keepdir, etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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