Getting started with Vim on Windows

I am not a new Vim user, but I have never used it as my main editor. I've learned the basic movement and editing commands, which I am using in Vi modes in different editors - Sublime Text's Vi mode, Visual Studio's extension - VsVim, and others. As now Vim can be used as fully featured C# (by Omnisharp) and F# (by vim-fsharp) environment, I want to use Vim as my main development environment. The first step for that is installing and setting up basic configuration.

Installing ConEmu

I'd like to use Vim in the terminal and ConEmu console emulator is a good fit for my needs. As I am Chocolatey user, installation is easy - just type in command in console:

choco install conemu

Then configured it to use Solarized theme and start PowerShell by default.

Installing Vim

Same as with ConEmu, install Vim using Chocolatey:

choco install vim

Basic Vim configuration

Open the terminal (ConEmu) and CD into the home folder (usually C:\Users\YourUserName). Create Vim configuration file .vimrc here:

echo $null >> .vimrc

Open .vimrc and add following lines:

" Enable syntax highlighting
syntax on

" Enable auto indentation custom per file type
filetype plugin indent on

" Set tabs to 4 space chars
set tabstop=8 softtabstop=0 expandtab shiftwidth=4 smarttab

" Set backspace behavior in insert mode
set backspace=indent,eol,start

" Disable beeps
set noerrorbells visualbell t_vb=
autocmd GUIEnter * set visualbell t_vb=

All settings are described well with comments except auto indentation. As described in Vim Wiki filetype plugin indent on allows to customize indentation per file type and it will use indentation scripts located in the indent folder of Vim installation.

Install Pathogen plugin manager

Vim has lots of different useful plugins, but managing those manually might be hard. Pathogen is a tool which manages Vim's runtimepath so that is easy to locate plugins.

To install Pathogen first create new folder vimfiles and two sub-folders - autoload and bundle in your home directory:

mkdir vimfiles\autoload
mkdir vimfiles\bundle

Then download Pathogen into vimfiles\autoload directory:

curl -OutFile vimfiles\autoload\pathogen.vim

Now configure Vim to use it. Open .vimrc file and on the top add this line:

execute pathogen#infect()

Colors and themes

ConEmu supports terminal with 256 colors and it is possible to configure Vim to use color syntax highlighting in it. There are some issues with different Vim versions and color schemes which is described on ConEmu page.

Before enabling colors in Vim, install the theme first. I am using zenburn theme.

git clone vimfiles\bundle\zenburn

Now configure Vim to use 265 colors in terminal (as described on ConEmu page) and set theme:

" Set colors in console
if !has("gui_running")
    set term=xterm
    set t_Co=256
    let &t_AB="\e[48;5;%dm"
    let &t_AF="\e[38;5;%dm"
    colorscheme zenburn

Known issues

Issue with key bindings

After installation and configuration I tried Vim's :help to find out how to start vimtutor - interactive Vim's tutorial. The issue I came up was that I was unable to navigate to required section with keys - Ctrl+]. Unfortunately it doesn't work and it seems that Ctrl is ignored - only ] gets sent as command. I tried to find solution to enable this key combination, but couldn't find any. Only solution is to remap it to different keys. So I remapped it to use F3 key. Add these lines to your .vimrc to remap it:

" Key mappings
map <F3> <C-]>

Issue with colors

Sometimes colors look strange when scrolling, but it is ok to live with that.


Copying/pasting in Vim is quite different than in other editors and sometimes you have to copy into Window's clipboard. To do that use copying into the + buffer. Select the text and type command:


For novice user this command might look strange, but is quite simple:

  • " - means that you are using named buffer,
  • + - is the name of the buffer - + in Windows is Clipboard,
  • y - is copying (yank) command.