The Quest for the Ultimate Vim File Browser

Sean
4 min readApr 12, 2021

I’ve tried netrw, NERDTree, Vim Ranger, a modified version of fzf.vim and even simply using the command window with path/** . None of these has quite worked for me and I’m forever fighting Vim trying to find a decent way to look at a folder structure and preview files before I commit to opening them.

Netrw

For some reason netrw can’t deal with Vim’s concept of buffers. If you have a netrw buffer open it’s almost impossible to remove it from the buffer list. A netrw buffer won’t even respond to bwipeout (the duke nukem of Vim buffer commands). Another crazy thing it does is creates a new one of these indestructible buffers almost every time you go into a new folder.

It has a nice concept of previewing buffers, you press “p” to open a buffer in a preview split so you can see it’s contents but that file will be added to your buffer list whether you actually want to edit it or not.

NERDTree

NERDTree is pretty good but it’s problem is that it feels like it’s an attempt to emulate something like Sublime or VSCode’s file browsers. The side-split view thing is a little bit annoying because Vim doesn’t treat splits like a fixed sized element. If you try to open a third split and move it around NERDTree will change size and maybe end up in weird place whereas in VSCode and Sublime the file browser view knows it’s something separate to a file view and it stays in position.

Again, NERDTree also doesn’t have the concept of previewing buffers without opening them so it’ll fill up your buffer list with every file you preview.

Vim Ranger

This is one I don’t hear that many people talk about. Ranger is wicked file browser for the terminal, it’s a stand alone program that’s really useful and has Vim-like mappings. I totally recommend it. I’d been looking for a decent Ranger plugin for Vim for some time because it seems like an obvious thing to exist.

There is one that’s pretty darn good, and as a part of Ranger’s behaviour it allows you to preview files without opening them as buffers. Ranger isn’t that well known for some reason and this plugin has taken a while to properly emerge. I’ve been using it on Linux for a while mainly because it’s the only file browser I’ve found that works like the MacOS Finder with column-style folder previews.

The only shortcoming I’d say Ranger has is that you have to use a whole separate program rather than having a small Vim plugin and because of this, it’s a little sluggish to load (really not that sluggish though). Again this is a great choice and well worth checking out if you’re a Linux user anyway.

fzf.vim

This is a bangin’ plugin that I use for doing all kinds of fuzzy searching in Vim. It’s totally indispensable to me at this point. I use it for fuzzy seraching files, contents of files and switching buffers. These are all things that Vim can actually do natively but fzf.vim does them much faster and much more visually. It also has a file preview feature.

But for some reason I’ve yet to find a file browser built with fzf. It’s crazy! There’s even a section on the github page that gives an example of a rudimentary one but it’s not included as a feature of the plugin.

I’ve made a fork of the project and added my own fzf browser under the command :Browse , it’ll open a fzf instance which gives you a list of files and you can traverse your file system. It could do with a little more work to make it slightly smoother by using fzf’s in-builtreload function but I haven’t found a way to do that yet. You can check it out here.

--

--