I am creating a .vimrc that will be shared by all the users on the system, ie it will be set from /etc/skel. However after starting it should be able to load the users own customizations, which normally go into .vimrc itself. The ~/.vimrc file its actually symlinked to the central file, which should then load the users own customisations, which could be a file named ~/.vimcustomrc.

What command, if there is one, should be used for that?

It is something like the Apache webserver looking in /etc/apache/conf.d and adding the vhosts the to the default apache2.conf or additional repositories being loaded from the /etc/apt/sources.list.d directory


You can add source command at the end of the main .vimrc, like so:

if filereadable(expand("$HOME/.vimcustomrc"))
   execute "source " . expand("$HOME/.vimcustomrc")

The right way to do this is to follow the explanation in :help startup and to put customizations that are to be shared by all users into $VIM/vimrc or /etc/vimrc, depending on how Vim was built. Execute :version and look for system vimrc file. See also :help system-vimrc.

The files in /etc/skel are generally used to initialize a user's private customizations and not to be the system-wide customizations.

Then each user can customize Vim they way they want to by editing their ~/.vimrc file, which you've initialized in /etc/skel, the way it's documented and the way everyone else does instead of having to discover and use some other file, in this case ~/.vimcustomrc, which no one else in the world uses. This will make maintaining Vim easier for you and for your users.

  • The system I am devising is for myself. I use separate accounts for different tasks on Linux, such as managing a website in one account name and doing programming and compilation in another. I want a common configuration for the commonly used tasks and customized configurations for each account and the work done with it. – vfclists Apr 20 '17 at 13:57
  • If I want to share some plugins across all accounts, where should they be stored, and how should they be configured in .vimrc or $VIM/vimrc? – vfclists Apr 26 '17 at 4:57
  • They go in $VIM/vimfiles, that is, in the subdirectories $VIM/vimfiles/plugin, $VIM/vimfiles/syntax, etc. See also :help vimfiles. There is no need to specify their location in any vimrc: that location is already in the default value of 'runtimepath'. If you need to set any plugin-specific global variables for their configuration, then I suppose those settings could go into the system vimrc, which is usually either /etc/vimrc or $VIM/vimrc. You can find out how your Vim is configured by executing :version and looking for the system vimrc file:. – garyjohn Apr 26 '17 at 6:08

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.