Today’s topic is the first continuation of Distributing configuration files and as the title already denotes, it is concerned with Vim, specifically with using it in heterogenous environments (read: Linux and window$/Cygwin).
Unfortunately, the window$ version of Vim searches different paths for configuration files than the Linux version does. That means that even though there probably is a git version for window$, it won’t help us much as window$ doesn’t know softlinks. So we must use a little trick…
When I’m forced to work under window$, I install Cygwin to make the work a lot more enjoyable. It has packages for practically everything I need, the most important of which is a usable terminal. Unfortunately, the Linux file system it simulates conflicts with window$’ own one, so there typically arise problems when using an editor started from this environment.
To make things worse, Cygwin has problems with ntfs’ file properties (ownership and access rights) and with handling the different line endings of Linux and window$ files. Therefor, I prefer installing the window$ version of Vim which does not suffer from these problems. Of course, I still want to use the same settings for it that I use on my PC at home…
Coping with textmode hassles
This is very important! You need to make sure that the directory you check your settings out to is mounted in binary mode. Otherwise, you won’t get much further than checking out: The first commit, branch or tag you do will completely screw up your git directory as it cannot deal with textmode’s line endings (aka <CR><LF> instead of just <LF>, check out the Cygwin website for details).
If you use textmode per default, you at least need to mount the directory into which you will check out your configs in binary mode. Doing this is easy in Cygwin. You can see your mounted directories with
mount and the respective commands with
mount -m. The important flags are
-t for text- and
-b for binary mode.
As an example, let’s assume you want to mount User’s
$HOME directory in binary mode:
mount -f -s -b "C:/cygwin/home/User" "/home/User"
Getting the window$ version of Vim to use your settings
I assume you still know how to retrieve the settings via git from the first part of this mini-series, so I’ll skip that as it works just the same way under Cygwin. Once you’re done, rename the file
C:\Programs\Vim\_vimrc and create a new file with the same name and edit it:
set runtimepath+=C:\cygwin\home\User\.config\vim\.vim set runtimepath+=C:\cygwin\home\User\.config\vim\.vim\after source C:\cygwin\home\User\.config\vim\.vimrc
Replace User with your username under window$ and the next time you start the window$ version of Vim, it should use the settings imported with git.