To be frank, getting vim and Windows to play nice is a bit of a pain in the ass. Here are some tips and tricks to get the most out of vim on Windows.
Power Tools
If you want a pretty slick setup without too much hassle, check out Fabio Akita ‘s vimfiles. Here’s a list of some of the bad-ass plugins that I find particularly useful (full list can be found on the GitHub repo):
- fugitive
- Command-T
- surround
- rails
Make it Sexy
I absolutely love the Solarized theme. If you use Akita’s vimfiles, you already have it installed (courtesy of yours truly).
Here are a couple other cosmetic changes from my .vimrc:
if has("gui_win32") || has("gui_win32s")
set guifont=PragmataPro:h10
set background=dark
colorscheme solarized
endif
" Taggle Solarized light/dark background using F5 key
call togglebg#map("<F5>")
" No space between lines
set linespace=0
" Make csharp code use 4 spaces for tabs
autocmd FileType cs setlocal expandtab shiftwidth=4 softtabstop=4
If you don’t already own a copy, go buy PragmataPro – thine eyes shalt thank thee.
Visual Studio
Add gVim as an external tool. Go to Tools > External Tools > Add and plug in the following:
Title: &Vim Command: C:\Program Files (x86)\Vim\vim73\gvim.exe Arguments: --servername VimualStudio --remote-silent +"call cursor($(CurLine),$(CurCol))" $(ItemPath) Initial directory: $(SolutionDir)
By specifying --servername VimualStudio, you’ll have a dedicated vim process just for Visual Studio.
Fixing Problems
Here are some problems I came across. If you have any of the following problems, see if the given solution will work for you.
#1 – CommandT::VIM Conflicts with ::VIM
line 74 NoMethodError: undefined method `command' for CommandT::VIM:Module
Solution: See this page for help.
#2 – CommandT Crashes Vim
Solution: Following the advice here solved my problem. It appears that there’s a bug in vim that was patched as of version 7.3.088.
You may also have to build CommandT. To do so, you’ll need to have the Ruby DevKit installed. Then, enter the following in shell (change the paths to reflect your system):
c:\RubyDevKit\devkitvars.bat cd C:\Users\Charles\vimfiles\bundle\Command-T\ruby\command-t ruby extconf.rb make
#3 – Fugitive’s GDiff Fails
Error detected while processing function <SNR>12_BufReadIndexFile..<SNR>12_ReplaceCmd: line 26: E302: Could not rename swap file Press ENTER or type command to continue
Solution: One of the answers on this StackOverflow question should do the trick.
#4 – Mysterious Blank Screen
If you have a blank screen until you press a key, vim probably ran into a problem and displayed a warning. In my case, I needed to tell CSApprox to shut up:
" Put this at the very top of your .vimrc:
let g:CSApprox_verbose_level=0
Anything Else?
If there’s something that you think I’m missing, let me know!