0

I'm adding some setup to my .vimrc, and what I want to do is to be able to run a command using the command line before the vimrc is executed. I tried vim -c 'command' but it runs after the .vimrc.

The reason I want to do is I want to be able to set a variable which decides my setup in vim.

nvim answers are also ok

4

If you run vim --help you'll find the answer...

$ vim --help | grep vimrc

--cmd <command>      Execute <command> before loading any vimrc file

Some additional details under :help --cmd ...

--cmd {command}

{command} will be executed before processing any vimrc file.
Otherwise it acts like -c {command}.  You can use up to 10
of these commands, independently from "-c" commands.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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