How to make Vim's file browser open a file in a new buffer?

Neth picture Neth · Oct 12, 2010 · Viewed 8.4k times · Source

Sometimes I start Vim by pointing it at a directory, but I'm not certain yet which file I'll need to change, so I end up looking through several files.

Is there a way to make the file browser open a selected file into a new buffer so that the file browser is still available without having to reopen it with :e path/to/directory ?

Answer

Randy Morris picture Randy Morris · Oct 12, 2010

I'm not sure if you can have it open in a new buffer, but you can have it open in a new split using o or v for a horizontal or vertical split respectively.

You could also preview the file using p which runs :pedit <fname> where <fname> is the file under the cursor. This opens a new split window but doesn't change the cursor focus or position. You can close this window with :pclose or simply :pc.

See :help netrw-browse-maps for more information.