File browsing in Vim
Well-heeled Vim users will no doubt see the following as being pretty obvious. For anyone else like me fumbling around with Vim to the point of giving up, I hope this at least saves you the time I spent until the small hours of the morning!
The way I used to think
Coming from working with text editors like jEdit which, like others, has a file browser in a split pane, I had been trying to reproduce this in Vim.

However, since upgrading to Vim 7, this had been causing irritations, like this routine to open a file:
- Select a file in the left pane.
- Click in a window in the right pane to indicate that was the one to open it in.
- Go back to the file in the left pane and Shift-p to open it.
Forgetting to select the window to open it in meant it would open in the left pane instead, which was supposed to be my file browsing pane.
Not only that but for whatever reason I was getting an odd refresh when I moved to another application and back to Vim. This refresh was annoying enough to have me spend time reinstalling netrw, attempting to compile Vim for myself (which failed) and even taking time to try out Textmate.
All in all I was getting pretty fed up and was even converting the Euro to Aussie Dollar to see if I had enough pocket money to buy Textmate. Luckily, the stubbornness of anyone who has put the time into learning Vim wouldn’t go away and I stopped to have a look at the new tabs in Vim 7. It was then that I realised I’d been thinking about this all wrong…
Vim is about modes
My mistake was to think of any window in Vim as having a specific role and ignoring vim’s modal nature. I realised that file browsing was always there in the background as I edited a file and I didn’t need to have windows specifically assigned to file browsing.
The joy of :Ex (very poor, I know!)
The magic lies in the fact that the file browsing functionality of netrw is following you around as you go. For example, if I open …/Sites/zend_framework/library/Zend.php in a window…

…and then hit :Ex I will be in that files directory…

However, if I open a file from another directory in another window hitting :Ex for that window will bring up it’s directory. This then allows me to have a contextual file browser available at any time without having to move my hands from the keyboard.
Admittedly this is not exactly a nirvana attaining moment of enlightenment, but it’s certainly one of those “Aha!” moments that reinforces your faith in your tools and the time spent learning them.

June 21st, 2006 at 11:44 am
I was as frustrated as you and found a couple of other useful ex-commands. Vexp, Hexp, and Sexp.
I came from an emacs background and liked being able to mark multiple files while browsing a directory and rename, copy or execute any other command on them. If the same functionality is here in vim I haven’t found it yet.
June 21st, 2006 at 6:23 pm
Thanks for this little article. I never even knew about :Ex. Funny. I learn something new about vim every day. How deep is this rabbit hole? :)
November 13th, 2007 at 3:46 pm
About that “odd refresh” — see :help g:netrw_fastbrowse you probably should have it set to 1 or 2.
May 1st, 2008 at 10:03 pm
thanks for the Vim tip. I too spent ages (actually about three years) tryuing to recreate file browsing from a folder tree in Vim. The thing is I didn’t want a solution that required a complex set of instrucitons in the .vimrc file. You’re right the answer is – just use :Ex where ever you go.
PS love the rounded corners!
August 2nd, 2008 at 4:28 pm
Here’s something I just found by accident:
After using :Ex to get into the file browser, if you select a file and just hit v, vim will split the current view vertically and open the file.
August 2nd, 2008 at 4:38 pm
Better yet:
:help netrw-dir
Here’s a list of all the commands that work with the file browser, including: o Open file with a horizontal split v Open file with a vertical split c Make browsing directory the current directory - go up a directory
..and many more!