I'd like to have NERDTree shown everytime I start gvim empty, that is without passing any argument to it, starting simply to load files rather than to create a new one, such as just by issuing gvim (and not gvim myfile.txt).


The list of filename arguments can be obtained by calling argv(), so you could put something like this in your ~/.vimrc:

if empty(argv())

Note that putting a command in your ~/.vimrc, whose contents are executed before any plugins are normally loaded, requires that the source for that command be sourced first. Alternatively, you could put this in your ~/.vimrc:

if empty(argv())
    au VimEnter * NERDTree

That will delay the execution of the NERDTree command until after all the plugins have been loaded.

  • Thanks. The second code worked (, and the first resulted in "not an editor command"). The command is just NERDTree to start it.
    – user10767
    Jan 10 '17 at 14:39
  • 1
    @Chinggis6: Thanks. I updated the answer with the correct command.
    – garyjohn
    Jan 10 '17 at 14:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy