milushov
milushov

Reputation: 721

How to detect vim command-line arguments in vimscript?

I want to know when I should call RestoreSession() function and when not. Because when I open single file, I don't want to see my project's files, which i save to vim session before.

For example if I call vim like this: vim -n test.rb. How me to detect n key in vimrc? (I want use n key as something like custom indicator for my purpose)

It's all, small question :-)

Upvotes: 9

Views: 1261

Answers (2)

milushov
milushov

Reputation: 721

In private conversation, @Nicklasos suggest me another way how to do what I need - using argv() function. It is just:

if argc() == 0
  autocmd VimEnter * call RestoreSess()
end

Upvotes: 10

Nicklasos
Nicklasos

Reputation: 565

You can run vim with -c key (Execute command upon startup)

vim -c RestoreSession foo.txt

Also, you can write bash alias.

Upvotes: 2

Related Questions