1

I am writing a bash script about session management and what I want is if there's something in the arglist not to source the session.

But I couldn't find a way to check the length of :args

First of all how do I even assign the output of it into a variable?

1 Answer 1

4

You can use the argv() function:

$ vim a b c
:echo argv()
['a', 'b', 'c']

There is also the argc() function to get the length of the argument list (which is the same as len(argv())).


Note: I found this by going to :help function-list and searching for arg :-) I find :help function-list to be one of the most useful Vim pages when writing VimScript. Tattoo it on your arm!

It's also documented in some detail at :help argument-list.

1
  • this is indeed the answer
    – nikoss
    Nov 29, 2017 at 0:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.