John Debs
John Debs

Reputation: 3784

How can I see the file or directory named passed to Vim from the command line?

I'd like to set up my .vimrc so that NERDTree is open whenever vim (or MacVim) is called from the command line with a directory argument, but closed when vim is called with a file argument. I looked through the list of vim's built-in variables but couldn't find anything that looked promising.

Upvotes: 3

Views: 134

Answers (1)

John Debs
John Debs

Reputation: 3784

Looked up arglist per Alligator's advice. Ended up with the following:

if argc() > 0 && isdirectory(argv(0))
    autocmd VimEnter * silent NERDTree
endif

Upvotes: 3

Related Questions