grigoryvp
grigoryvp

Reputation: 42483

VIM: how to put result of a colon command into a variable?

In VIM script, i want to check if VIM was started with command-line arguments or wthout. For this, i want to check a result of :args command that prints arguments. But how to put a result of :args inside an if() or a variable. Following wll not work:

let s:MyArgs = execute( "args" )

Upvotes: 2

Views: 481

Answers (1)

Luc Hermitte
Luc Hermitte

Reputation: 32946

You need to play with :redir. I have encapsulated this operation in a function there.

BTW, argc() should also answer your original need in a simpler way. (:h argc())

Upvotes: 5

Related Questions