Tuesday, May 7, 2013

Using VIM on Windows

If you're forced to use Windows at work instead of Mac OS or Linux and you're also a VIM user you're in for some fun. I struggled for a while with the best way to get VIM up and running on Windows. Sure you can simply install VIM from http://www.vim.org but then how do you set up your vimrc and pathogen and use git repos to setup things for you? I recently had to setup a new Windows 7 machine and this is what worked for me.

First go to http://www.vim.org and install VIM. It put itself in C:/Program Files (x86) on my machine which is  fine. Upon launching it you get the basic VIM install which is black on white. Typing "echo $HOME" shows that VIM on Windows 7 has a home directory of C:\Users\<username>. If you type "echo $MYVIMRC" it will still be the default installation of C:\Program Files (x86)\Vim\_vimrc. Notice that it is NOT .vimrc but rather _vimrc which is the major difference running on Windows.

I like to start my VIM installation with a bunch of dot files from Hashrocket called dotmatrix. Using Git on Windows is a bit beyond this post but start with a client like SourceTree or Github's client. Copy all the files directly into your C:\Users\<username> directory. Now to convert this installation to Windows simply rename the .vimrc file to _vimrc and the .vim directory to vimfiles.

The next thing I do is install the jellybeans.vim color scheme. To do this copy all the files to the root of the vimfiles folder in your user directory. Then create your own .vimrc.local file to add the jellybeans theme to your VIM installation. Mine looks like this:

I first override the Comment style to not be italicized because it makes it extremely hard to see where things line up. Then I instantiate the jellybeans color style.

At this point you're pretty much ready to go. Add any additional VIM customizations to the .vimrc.local file so if you ever update the Hashrocket files you won't lose your changes. Happy VIMing!

No comments:

Post a Comment