Vim edit a file with a user-vimrc but still load all previous initializations

settingsvimvimrc

Checking the man page for vim says it's -u switch that lets me choose a different vimrc file

   -u {vimrc}  Use the commands in the file {vimrc} for initializations.  All  the  other  initializations
               are  skipped.   Use  this to edit a special kind of files.  It can also be used to skip all
               initializations by giving the name "NONE".  See ":help initialization" within vim for  more
               details.

But, i would like to retain the default configurations and just add few more setting from my user-vimrc file. Command i use is

$ vim -u user.vimrc *file-to-edit*

Any way to achieve this?

To be more specific of what I am losing with current behaviour:

Without my vimrc, I get a default colorscheme and when i give my user.vimrc, the colorscheme is being switched off. I am not able to track how to set the colorscheme which is given by default. There is no default .vimrc.

Note: I am on a shared env, so i don't want to create a .vimrc. I will just source my vimrc which will be available only for me.

Best Answer

The .vimrc is just a Vimscript file like any other. You can source it via

$ vim --cmd "source path/to/user.vimrc" *file-to-edit*

With this, it will come first. There's also the -S {file} command-line argument, which would source it at the end (which makes this unsuitable for plugin initializations, but would work if you just have some mappings and settings).

Related Question