It is easy to use vimscript to determine if a filename was specified to vim by using argc()
. Is there a way to determine if the -
flag was given to specify piped input was given to vim? It doesn't count piped input as a filename and argc()
is empty.
Edit
Thanks to the wonderful accepted answer below, I have a way to open NerdTree if there are no filenames and stndin is not being used.
let wmuse_nt = 0
autocmd StdinReadPost * let wmuse_nt = 1
autocmd vimenter * if !argc() && wmuse_nt == 0 | NERDTree | endif