Dimitar Slavchev
Dimitar Slavchev

Reputation: 1667

How to set "args" from vimrc?

I want to create a different lvimrc for my project that will set "args" to my source files.

Currently I do it during runtime by:

:argadd src/*.c inc/*.h

And I want to have that executed at startup. I always start vim from the root of my project.

Upvotes: 1

Views: 160

Answers (2)

Conner
Conner

Reputation: 31060

To execute commands automatically you can use autocommands (:help autocmd). If you're using an lvimrc, you could do

au VimEnter * argadd src/*.c inc/*.h

EDIT: Changed argsadd to argadd. That is the correct one.

Upvotes: 3

romainl
romainl

Reputation: 196626

You could create an alias in your ~/.bashrc or whatever:

alias lvim='vim +argadd\ src/*\ inc/*.h'

or add something like this to your ~/.vimrc:

if ( getcwd() == '/path/to/project' )
  exec( 'argadd src/*.c inc/*.h' )
endif

Upvotes: 5

Related Questions