The downside of using a .vimrc however is, as long as you aren't using a central home directory that is mounted via NFS on all your hosts, you have to do this on every host you work on.
There is another option: vim also takes settings from environment variables.
This becomes interesting along with another tidbit that is not so widely known: SSH clients can set environment variables on the host you connect to.
On Unix/Linux you can configure this in
If you are using PuTTy on Windows there is also a way to set environment variables:
(Don't forget to save this to your default settings.)
With this setting the SSH client will set the environment variable on the host when you connect (if the host permits it), vim will read the variable on startup and use it as a configuration.
Sadly this will not work out of the box since SSH daemons are usally configured to accept only very few environment variables from the client. A default configuration from Ubuntu looks like this:
AcceptEnv LANG LC_*
It only allows the variable
LANG and all variables that start with
LC_, allowing you to set the language of the output regardless on what language is configured as default on the server. To allow the vim configuration variables you have to extend this:
AcceptEnv LANG LC_* VIMINT
Of course, this will have to be done again once on every server you work on, but if you are using a configuration management environment like ansible, puppet or such this can be deployed easily and everybody working on the servers can benefit from it.
You see, there are various ways to do this, what's the best way to do it depends on your environment.