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
).
1 Answer
The list of filename arguments can be obtained by calling argv(), so you could put something like this in your ~/.vimrc:
if empty(argv())
NERDTree
endif
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
endif
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.– user10767Jan 10, 2017 at 14:39 -
1