vim - vimscript detect piped input -
it easy use vimscript determine if filename specified vim using argc()
. there way determine if -
flag given specify piped input given vim? doesn't count piped input filename , argc()
empty.
edit
thanks wonderful accepted answer below, have way open nerdtree if there no filenames and stndin not being used.
let wmuse_nt = 0 autocmd stdinreadpost * let wmuse_nt = 1 autocmd vimenter * if !argc() && wmuse_nt == 0 | nerdtree | endif
you use autocmd run before or after vim reads stdin stdinreadpre
or stdinreadpost
events. copied below.
stdinreadpost stdinreadpost after reading stdin buffer, before executing modelines. used when "-" argument used when vim started --. stdinreadpre stdinreadpre before reading stdin buffer. used when "-" argument used when vim started --.
Comments
Post a Comment