DEV Community

Kelly Stannard
Kelly Stannard

Posted on • Edited 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. Anyone serious about file editing should learn how to fly to a file with little more than a thought.

edit: I switched from splats to :find thanks to James's suggestion and also gf. gf works very well in a conventional Rails app. Both are orders of magnitude faster than NerdTree.

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.