How to define vim command line arguments in vimscript?

I want to know when I should call the RestoreSession () function, and when not. Because when I open a single file, I don’t want to see the project files that I save before the vim session before.

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

That's a small question :-)

+8
vim
source share
2 answers

In a private conversation, @Nicklasos offers me another way how to do what I need using the argv () function. It's simple:

 if argc() == 0 autocmd VimEnter * call RestoreSess() end 
+8
source share

You can start vim with the -c switch (execute the command at startup)

vim -c RestoreSession foo.txt

Alternatively, you can write the alias bash.

+2
source share

All Articles