Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to get switch over to vim as my primary editor and I've installed the nerdTree plugin, but now when I try and use vimpager to replace less I get

Error detected while processing VimEnter Auto commands for "*":
E492: Not an editor command: NERDTree  

I've narrowed it down to this line in my .vimrc, but I don't know much about configuring vim, I got this .vimrc off the internet.

autocmd VimEnter * NERDTree 

My best guess is that vimpager is trying to disable plugin, but the .vimrc is trying to load it, so they're getting an error.

Any advise on resolving this?

share|improve this question
See also stackoverflow.com/questions/1447334/… – Mikel Apr 23 '11 at 8:49
up vote 2 down vote accepted

The correct fix is to move

autocmd VimEnter * NERDTree

out of your ~/.vimrc and into ~/.vim/after/plugin/NERD_tree.vim.

That way, the autocmd only gets run if NERD_tree has also been loaded.

And to be more correct, you should probably make it

if exists("loaded_nerd_tree")
    echo 'loaded_nerd_tree' . loaded_nerd_tree

that way if the plugin is uninstalled, your after script won't still try to use the plugin.

share|improve this answer
Thanks that worked. I put autocmd VimEnter * NERDTreeerd_tree autocmd VimEnter * wincmd p inside the if instead though. Otherwise when I start vim I need to press enter to continue – Joshua Olson Apr 23 '11 at 17:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.