When dealing with .vimrc configuration files in Linux and Windows (two systems I’ve been using so far) and trying to keep configurations cross-platform, I’ve found mainly two solutions:
-
Create a new folder for vim files in
/home/user, so both systems have the same vim dirname (instead of default.vimin linux andvimfilesin Windows), and useset runtimepathto get this new folder;set runtimepath=~/vim_local,$VIMRUNTIME
source ~/vim_local/vimrc -
Create a bunch of os conditions (like
has("32")) in.vimrcwhen needed, based on platform or capabilities, but keeping the original unix names and creating symlinks in Windows home folder to the original files (vimfilesto.vimsomewhere, maybe a.vimdir in Windows home, or even a dropbox folder). (I haven’t tested this approach in older Windows versions like XP).
Which solution do you prefer, and why? What are the disadvantages from each solution? Which other solutions do you have? (You can post your own .vimrc here as well to discuss.)
If you use some source control in your .vimrc configuration files, do you version your plugin files as well (so when “deploying” your config across computers, you only do a checkout/clone from your repository)? A lot of people are using pathogen and keeping each plugin inside it’s own folder (usually a git repo from github). Does it make sense to version control a plugin that is already a repository from elsewhere?
I use something approximating option 2, but probably considered option 3. I keep everything in a single folder called either
~/.vimorc:\vim\vimfiles. These are version controlled with Bazaar and held on a server with sftp access. When installing vim on a new Windows machine (with Bazaar), I put it inc:\vim\vim73and do:On Linux machines I do:
vimrc_linker.vimcontains one line:which opens up the file called
vimrcwhich is stored in.vim(orvimfileson Windows). This allows me to keep my vimrc under the same version control as the rest of the.vimdirectory. Since I use cygwin Bazaar on Windows usually, I keep all of the plugins with unix line endings to avoid compatibility issues (both Windows & Linux vims cope with unix line endings in plugins, but the Linux one doesn’t like Windows line endings).The use of version control allows me to keep all the PCs that I use in sync very easily and if I install a plugin and don’t like it, I can very easily revert the change without having to think about which files were installed by that plugin (the VCS tells me).
As for the os conditions, I use
has("win32")etc to differentiate. However, there are very few situations that require this differentiation, so it’s a minor inconvenience. My vimrc is 1000 lines long (it has quite a few functions that I’ve never got round to splitting out into plugins) and only about 10-15 are inside thehasblocks:,x) for maximising the GVim window: this is done differently in Windows & Linux