DEV Community

Kelly Stannard
Kelly Stannard

Posted on

NERDTree an anti-pattern?

Hi everyone, I wanted to talk about NERDTree because I have seen it recommended in basically every Vim guide but I think if you want to be serious about improving productivity with Vim then using NERDTree is a mistake. I have paired with people who use it and when the directory tree pops up I know I need to sit back and relax for a few minutes and maybe catch up on my meditation.

These are the use cases for NERDTree as explained in the readme. I will cover them and suggest a faster, preexisting alternative.

Visual browsing

This can be useful when you are first getting to know a project. But, the need for this would drop to zero pretty quickly as you become familiar. Some possible alternative ways to visually browse a directory:

  • ls on the command line
  • Vim's default directory browser that is available by opening a buffer on a directory.
  • find <path> | less is available everywhere and the output can be learned fairly easily.
  • tree can be installed and outputs a traditional directory tree.

Opening files

This I think is where workflows involving directory trees start taking a turn for the worse as you can get in the habit of using NERDTree all the time. Maybe not many people know this, but the Vim command mode comes with a splat and double splat operator that work well with tab completion to find and open files that you may not remember the exact location of.

For example, I see a class named FooBar and by convention I know that it is probably in a file named something like foo_bar. With the splat operators I can probably open the file with the following keystrokes:

:e **/*foo_bar<tab><enter>

This will generate a list of all files with foo_bar in the name as tab completions. This takes usually a couple seconds as opposed to a minute or two navigating a complex file hierarchy in a tree.

Other operations

I don't think I have ever seen other operations used, so I can't really comment. I think most people use other tools already. 🤷‍♂️

Thanks for your time. Let me know if there is some killer feature in NERDTree I missed or other alternatives in the comments.

Top comments (3)

Collapse
 
jamestthompson3 profile image
jamestthompson3

I personally don’t think NERDTree is necessary to for productive file navigation. Navigating via symbols or with your path set correctly is much faster. Check out this excellent post about project navigation. If you need or would like a file browser, I would recommend checking out something like vim-dirvish.

Collapse
 
kwstannard profile image
Kelly Stannard

Wow, I had no idea about find and path. Thank you for that link!

Collapse
 
moopet profile image
Ben Sinclair

I think NERDTree is pitched at people coming from IDEs. It's a similar mindset to using tabs to represent files.

In the last few years, a lot of people have written about how a file pane doesn't make sense with Vim, and how tabs represent workspaces rather than buffers. Personally, I think it belongs to a group of plugins that don't fit the way I work with Vim at all. If I'm browsing through someone's post about how to start using Vim, and they start off by recommending NERDTree, I usually bail out around that point.