Skip to content

Instantly share code, notes, and snippets.

@danwagnerco
Created June 22, 2015 20:43
Show Gist options
  • Save danwagnerco/36295f7f92f4bd5506fa to your computer and use it in GitHub Desktop.
Save danwagnerco/36295f7f92f4bd5506fa to your computer and use it in GitHub Desktop.
This is a Windows-specific walkthrough for installing Vim, Vundle and ConEmu

Vim, Vundle and ConEmu on Windows

Let's start by getting it out on the table: Sublime Text is great, and version 3 should no longer be considered "abandonware" as of build 3065. Sublime Text served me very, very well over the years. That said, trying out new things is a major part of leveling-up, and in that vein Vim deserves a go. (And have you seen some of those thoughtbot guys flying around in Vim? It's awesome!)

Getting Vim up-and-running on your Windows machine doesn't have to be an all-day project. In this post, we'll walk through:

  • Installing gVim, which gives us both the "classic" command line version as well as the graphical version
  • Installing Vundle, the best way to handle Vim-enhancing packages
  • Installing ConEmu, a supercharged command line emulator for Windows

Let's get after it!

Quick note before we get started: whenever you see text that looks like this:

> something

That means we're executing "something" from the command line. ConEmu is my recommended tool for doing command line work on Windows, but since getting ConEmu up-and-running is part of this walkthrough I'll be using regular-ol' cmd.exe.

End of the notes section. NOW let's get after it!

1. Download the gVim installer

As of this writing, the latest-n-greatest is version 7.4, so that's what we'll get from the Vim download page:

http://www.vim.org/download.php

Download the MS-Windows version and you'll wind up with a nice executable.

2. Run the gVim installer as an administrator and get through the basics

If you're an admin on your machine, go ahead and double-click on your recently-acquired gVim74.exe file and you'll see a very familiar set of wizard-style screens. If you are NOT an admin, right-click the gVim74.exe file and select "Run as Administrator" -- this will ensure all the necessary files are installed. (This means that if you aren't an admin, stop! Go get yourself admin status right now!)

[vim-install-01.png] You bet! Click "Yes" y'all

[vim-install-02.png] Of course "I Agree" ya dingus

The first time we're actually going to adjust the defaults is on the "Select the type of install:" screen. We want the full installation, so select "Full" before clicking "Next".

[vim-install-03.png] Pick the "Full" option here

The next step is another step away from the default. You're going to want to install to your User directory (often referred to as your home directory) rather than the typical "Program Files" destination. On my laptop, that means:

C:\Users\danie_000\Vim

Once you've selected your User directory, click "Install" and BOOM!

[vim-install-04.png] Pick that home directory and then let it rip!

Now, for the moment of truth. Open up a command window (you can type "cmd" into the Search Everywhere box if you're using the Metro interface), navigate to a directory with a text-ish file and try gvim the_text_file.txt:

> cd C:\Some\Directory > gvim the_text_file.txt

Are you looking at the file in gVim? If so, congrats -- let's keep the streak going by starting on the Vundle install. But what if you're greeted with this pain-in-the-ass message?

'gvim' is not recognized as an internal or external command, operable program or batch file.

WTF, right? You walked through the FULL install, the window said "Happy Vimming", this is bullshit. Why isn't 'gvim' recognized? Read on for the culprit...

Remember way back at the start of this guide? Way up in step #2, where you needed to run the installer as an administrator? Are you absolutely, 1,000% sure you did that? Because the gVim installer code attempts to put some very, VERY important batch files into your C:\Windows directory, and adding files to that folder is an admin-only joint.

These batch files, cleverly-named "vim.bat", "gvim.bat" and even "vimtutor.bat" (recognize the pattern?) are the secret sauce here. They are essentially shortcuts that enable the Windows command line to behave like a Unix or Linux terminal, and that's the name of the game with Vim. Long story short: if you want to be flying around the command line with Vim, you're going to need those batch files. Get in touch with your admin, get access and re-run the installer with administrative priviledges.

3. Clean up your Vim subfolders

Before we get to the magic of Vundle, let's do a little housekeeping on our Vim directory to make sure the install and setup is smooth like butter.

After following the Vim installation instructions above in steps #1 and #2, open up Windows Explorer and navigate your Vim directory. In my case, that means going here:

C:\Users\danie_000\Vim

Inside that directory, you should see 3 things:

  1. A folder named "vim74"
  2. A folder named "vimfiles"
  3. A file named _vimrc

[vundle-install-01.png] Vim directory pre-cleanup

Navigate into the "vimfiles" folder and delete everything except the folder itself. (Yes, seriously -- if you're feeling skittish, go ahead and check out some of those default folders, like "colors" for example... you'll find that they're all empty.)

Next, jump into the "vim74" folder. Inside "vim74", cut the folder named "autoload" and paste it into the "vimfiles" directory. At this point, "vimfiles" should have exactly one folder inside, the "autoload" directory you just cut from neighboring folder "vim74".

[vundle-install-02.png] "vimfiles" looking so fresh and so clean (clean)

Finally, you're going to create one last directory inside the "vimfiles" folder -- call this one "bundle", and you're done.

[vundle-install-03.png] "bundle" folder created

4. Install Git via mysisgit

Strictly-speaking, Git is a version control system, but Vundle uses Git to pull in the plugins from your _vimrc. Let's get it installed! Grab the super-easy installer from mysisgit first:

http://msysgit.github.io/

Once the installer downloads, double-click it and walk through the wizard (like so many before it). In this case, the version I am installing is 1.9.4-preview20140929, but regardless of the version the process should be super similar.

Right off the top, let's get this sucker into our User directory to keep it nice and portable, exactly how we did above with the Vim install. So, on the installer screen where you are asked to choose a destination, go ahead and put everything into a Git folder in your User directory:

C:\Users\<your_user_name>\Git

In my case, this path will look like this:

C:\Users\danie_000\Git

[vundle-install-04.png] Install Git to the top-level of your User directory

After that tweak, the defaults are all golden until until you land on the "Adjusting Your PATH environment" window:

[vundle-install-06.png] Install Git to run from the command prompt

Selecting the middle option, for "Use Git from the Windows Command Prompt", is critical here. Down the line we're going to want to clone from trusty old cmd.exe -- so make sure you pick that option.

After that, the remaining defaults are all A-OK, so go ahead and "Next" through them too, and before you know it you'll have git installed. Whammy!

[image of champ kind saying Whammy] Bet you didn't think I would throw it all the way back to 2004, did you?

You can verify the install by opening up cmd.exe and typing git --version from any directory:

> git --version git version 1.9.4.msysgit.2

You should be greeted by a courteous one-liner listing, you guessed it, the version.

[vundle-install-07.png] "git --version" at work

5. Configure cURL to work from the command line

We're getting so close -- I promise!

Vundle requires a program called cURL work properly, but don't trip -- it came along for the ride when you installed Git in the last step. Unfortunately, cURL is very *nix-y and does not play nice with the Windows command line out-of-the-box, so we're going to need to make a one-time adjustment.

Go to this gist (written by Vundle's author gmarik) and copy the text onto your clipboard:

https://gist.github.com/gmarik/912993

Here's the gist direct in case you don't want to go all the way to github for it:

[wpgist id="912993"]

Next, open up a text editor (Notepad will do just fine) and paste in what you just copied.

[vundle-install-08.png] The modification info from gmarik of Vundle fame

Save this file as "curl.cmd" inside the ..\Git\cmd directory that was installed as part of step #4 above. So, if you're following my recommendations, the full save path will look like this:

C:\Users\your_user_name\Git\cmd\curl.cmd

Here's what that looks like on my laptop:

[vundle-install-09.png] Making sure Curl will work from the Windows command line

Let's confirm that Curl is working by checking its version the same way we did for Git above:

> curl --version curl 7.30.0 (i386-pc-win32)

[vundle-install-10.png] Curl working like a champ

6. Install Vundle

We're finally to the actual Vundle install!

Open up a new command line and navigate to the "bundle" folder created in step #5 above. On my laptop, that command looks like this:

> cd C:\Users\danie_000\Vim\vimfiles\bundle

[vundle-install-11.png] Navigate to your freshly-created "bundle" folder

Then, run this command to clone the Vundle files into the "bundle" folder:

> git clone https://github.com/gmarik/Vundle.vim.git

You'll see some updates from Git regarding the status of the clone, and then you'll land on a new line. You can verify that the clone was successful by running Dir like so:

[vundle-install-12.png] Whaddup, now you've got a folder named "Vundle.vim" inside the "bundle" folder

All that's left to do now is update that juicy _vimrc file... and admittedly, this one was a bit of a challenge.

After working through the recommended guide (including the Windows-specific steps), I kept getting this error:

E492: Not an editor command: PluginInstall

Argh! But after hours spent slogging through a wasteland of "my .vimrc is broken, halp!" questions around the web, a solution was finally found. Save yourself the headache and the hours and check out my fully-functional _vimrc file, start-to-finish, which will work like gangbusters:

[wpgist id="5c56158314bc7957e661"]

Naturally, if any of those plugins are not to your liking, comment them out. When you'd like to pull down those vim add-ins, simply write vim +PluginInstall +qall at the command prompt from any directory (or :PluginInstall from inside Vim in normal mode). Check it:

> vim +PluginInstall +qall

[vundle-install-13.png] Let it rip!

Boom! Look at that glorious install go!

[vundle-install-14.png] Sweet berry wine!

If you were to stroll on over to your bundle directory, you'd see that those folders are now in place... damn it feels good to be a gangster. Quit Vim by hitting Esc to get into normal mode, then typing :q and hitting Enter.

7. Download the ConEmu installer

ConEmu is the command prompt you NEED to be using on Windows. Besides supporting tabs and being super-customizable, it's actively developed and supported by Maximus directly on Super User. The dude WILL answer your question, real talk. Did I mention it's also free ninety-nine?

http://www.fosshub.com/ConEmu.html

Download the ConEmu Preview Installer (32-bit and 64-bit) and you'll soon have another executable.

8. Run the installer as an administrator

No admin worries here -- the ConEmu installer has added it as a checkbox to the initial screen! Naturally, you want to run this one as an admin. Pick the x64 version if you're running a 64-bit version of Windows: otherwise pick x86.

[conemu-install-01-1.png] Pick the right install for your version of Windows

After putting in your admin password you'll find yourself at another wizard, and fortunately this time defaults are ALMOST perfect. The only recommended change is to install to your User directory, which for me is C:\Users\danie_000. This can be a little tricky considering what you see immediately after launching the installer! (Take a look at the last screenshot if you forgot... it TELLS you that the destination is inside Program Files!)

Don't worry though, you can still make your user directory the resting place for ConEmu by clicking the "Browse" button on the "Custom Setup" page.

[conemu-install-01-2.png] Let's get this little guy installed into our User directory instead

Inside the window that opens after clicking "Browse", you'll be able to navigate to your User directory (again, it'll look something like C:\Users\<Your User Name>) and create a new folder called "ConEmu" there as the destination. Easy as pie...

[conemu-install-01-3.png] Get a nice folder all set up for the install

And boom, you're done! Let's get into the fun stuff.

9. Open up that freshly-installed ConEmu app

[conemu-install-02.png] So fresh and so clean (clean)

JACKPOT. Let's go ahead and set up some super-handy shortcuts to make ConEmu the terminal we want AND need.

10. Set ConEmu to default into a different folder (that you pick)

First up, on initial open ConEmu will drop you into your Users folder... Not a bad place to start, but we can do better. Suppose that you keep your Git repos in a folder you created as C:\github like your boy does -- it would make the most sense to have ConEmu default to that directory, since you're undoubtedly using the terminal as part of your development process.

Go ahead and click the icon with three small blue lines, then select the "Settings..." option.

[conemu-install-03.png] Getting to ConEmu's "Settings..." pane

The Settings window will pop up momentarily. Now, click the "Tasks" option underneath "Startup" and you should see a window called "Predefined tasks (command groups)" with 7 options already built in, like this:

[conemu-install-04.png] Check out the already-created default tasks that come standard with ConEmu

Click the "+" button to add a new predefined task. "Group8" doesn't tell you much about what's actually going on here, so let's call it "github" instead:

[conemu-install-05.png] Rename this task to "github"

Now for the secret sauce. Inside the "Task parameters" field, add:

/dir "C:\github"

Then, inside the "Commands" field, add:

cmd.exe

Once you've made your modifications, your settings should look like this:

[conemu-install-06.png] Make sure you've got the /dir "C:\github" and cmd.exe options configured

Finally, this predefined task is something you're probably going to use on the regular, so go ahead and click the "Up" button until it gets into the first position.

[conemu-install-07.png] "I, am, number one." -Nelly

Click "Save settings" and BOOM, you've got your first Predefined task set up.

"But Dan", you're probably asking, "we were supposed to set up the start directory! Why do we care about adding this task?" That's a great question my friend. Now that we have our favorite folder stored as a task, getting ConEmu to load it up by default is easy cheesy!

Get to the Settings window again (by clicking the three blue bars icon again or using keyboard shortcut Win + Alt + p) and this time select "Startup" from the hierarchy on the left:

[conemu-install-08.png] Get to the "Startup" section

Now, instead of leaving the "Command line" option checked, click the "Specified named task" radio button and select your recently-added task ("github") from the dropdown:

[conemu-install-09.png] Choose "github" as the Startup option instead of the original setting

Click "Save settings" again and you're golden! You can verify that ConEmu now defaults into the folder you chose by restarting the app... you'll be in the right directory for sure.

[conemu-install-10.png] $traight ca$h...

Not only do we start in the right directory, but now we've got a super-easy shortcut for opening a new ConEmu tab into the C:\github directory. Go ahead and try it! Hit Win + n to open the predefined tasks window, then hit 1 to open a new ConEmu tab inside C:\github.

[conemu-install-11.png] DAMN that's a handy shortcut!

11. Set a Predefined Task for your _vimrc

Chances are, especially in the beginning, you're going to be tweaking your _vimrc A LOT... new Vundle packages, new settings, adjusting the colorscheme, whatever. A ConEmu predefined task that cues up your _vimrc file in gVim will save you lots of energy, so let's take what we learned in step 10 above and build out this tasty treat.

Create a new predefined task, and this time name it "vimrc". The "Task parameters" field should look like this, as we want to start in the Vim directory: /dir "C:\Users\danie_000\Vim". Finally, we want to pass the console an argument, which can be done from the "Commands" field. It should look like this: cmd.exe /k gvim _vimrc. In the screenshot below, the "vimrc" task has been moved to position #2:

[conemu-install-12.png] Gimme that sweet _vimrc editing

And that's it! Now, whenever you want to adjust your _vimrc, you can simply type Win + n then hit 2 from ConEmu. How simple is that!?

[conemu-install-13.png] Fugg yeah!

And with that, you have installed Vim, Vundle and ConEmu like a champ -- congratulations! Check yourself out in a mirror right now, because you are looking strong as an ox.

[Stevie and Kenny Powers image]

@iripu
Copy link

iripu commented Oct 22, 2017

I can't see any of the images.

@renwick530
Copy link

@danwagnerco
I can't see any of the images either.

@umnikos
Copy link

umnikos commented Jan 2, 2018

Thank you! Didn't know the bundle directory was supposed to be put directly inside vimfiles and not inside packages. Now vundle works!

@Limerin555
Copy link

Images no longer work.

vim_installation

@Cimaje
Copy link

Cimaje commented Feb 14, 2018

Hi, can you please update the images?

@Th3Lourde
Copy link

Yo,
I've been trying to configure vim on windows the entire freakin day, thanks so much!

@nunez85
Copy link

nunez85 commented May 19, 2018

Hi, can you please give us a link to your _vimrc file the error: E492: Not an editor command: PluginInstall?
Would greatly appreciate it since I can't see the image. So far, great guide and I love it, thanks!!

@ricalamino
Copy link

This does not work anymore. Do not use this!

@ragomez
Copy link

ragomez commented Oct 17, 2018

It works for me. Images not neccesary.
Only one thing, when you are 'installing' curl, you MUST specify windows version:

line 7
@set PATH=%git_install_root%\bin;%git_install_root%\mingw\bin;%PATH%
to
@set PATH=%git_install_root%\bin;%git_install_root%\mingw32\bin;%PATH%
or
@set PATH=%git_install_root%\bin;%git_install_root%\mingw64\bin;%PATH%

depending on your system (x86, x64).

@austindd
Copy link

Where should the _vimrc file be located? Vim does not appear to be finding it at all when I have it in the C:/Users/%UserProfile%/Vim folder, as well as the vimfiles folder within that. Not sure what to do about it. Any help would be greatly appreciated!

@ssamdani-1729
Copy link

Hi, Thanks for the guide. I'm wondering if you have new instructions for Vim 8 and how to install packages on Windows?

@JacoboGuijar
Copy link

Hi, this is a great post but images do not work. How is supposed to look like the _vimrc file?

@AlexanderBlum
Copy link

This is really awesome - except for all the dead image links that actually make it useless.

@danwagnerco
Copy link
Author

Hey @AlexanderBlum thank you for your kind words on this post.

In the years that have passed since originally putting this together, I have switched to using vim-plug for Vim 8 on Windows 10:

https://github.com/junegunn/vim-plug

You want to copy the "plug.vim" file, which is linked here:

https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

To your Vim 8 "autoload" directory. I installed Vim 8.1 to my top-level C:\ directory, so that means the destination on my laptop is here:

C:\vim\vim81\autoload

^-- once "plug.vim" is in that folder, you can take advantage of the :PlugInstall command inside Vim to download and install all the plugins that you specify in your _vimrc file. (The _vimrc file should be where you installed Vim, which is c:\vim\_vimrc for me.)

A copy of my full _vimrc, with all the plugins I'm using, is at the bottom of this note.

As far as ConEmu goes, it's still fantastic -- but again, over the years, I have changed my setup to use Cmder instead:

https://cmder.net/

^-- Cmder is built on top of ConEmu and, since I already had Git installed etc., I was able to make use of the "mini" download of Cmder. I have not modified Cmder much, except for adding a few shortcuts to make it easier to check Git statuses and logs, and "install" is really a misnomer as far as the "mini" package of Cmder goes since all I did was download the file and unzip it to its own top-level C:\ directory.

In case you're interested, here's my C:\cmder\config\user_aliases.cmd file, which allows me to type "s" at the command line as a shortcut for git status and "gll" at the commend line as a shortcut for git log -20 --pretty=format:"%C(yellow)%h %C(red)%cr %C(green)%cn %C(white)%s.

This is the c:\cmder\config\user_aliases.cmd file:

;= @echo off
;= rem Call DOSKEY and use this file as the macrofile
;= %SystemRoot%\system32\doskey /listsize=1000 /macrofile=%0%
;= rem In batch mode, jump to the end of the file
;= goto:eof
;= Add aliases below here
e.=explorer .
gl=git log --oneline --all --graph --decorate  $*
ls=ls --show-control-chars -F --color $*
pwd=cd
clear=cls
history=cat %CMDER_ROOT%\config\.history
unalias=alias /d $1
vi=vim $*
cmderr=cd /d "%CMDER_ROOT%"
vim=gvim $*
gll=git log -20 --pretty=format:"%C(yellow)%h %C(red)%cr %C(green)%cn %C(white)%s"
s=git status

Thanks again @AlexanderBlum, and here is my _vimrc file for reference.

This is the C:\vim\_vimrc file:

source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin

set diffexpr=MyDiff()
function MyDiff()
  let opt = '-a --binary '
  if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
  if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
  let arg1 = v:fname_in
  if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
  let arg2 = v:fname_new
  if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
  let arg3 = v:fname_out
  if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
  if $VIMRUNTIME =~ ' '
    if &sh =~ '\<cmd'
      if empty(&shellxquote)
        let l:shxq_sav = ''
        set shellxquote&
      endif
      let cmd = '"' . $VIMRUNTIME . '\diff"'
    else
      let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
    endif
  else
    let cmd = $VIMRUNTIME . '\diff'
  endif
  silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3
  if exists('l:shxq_sav')
    let &shellxquote=l:shxq_sav
  endif
endfunction

" Plug
call plug#begin()
Plug 'bling/vim-airline'
Plug 'kien/ctrlp.vim'
Plug 'tpope/vim-bundler'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-dispatch'
Plug 'tpope/vim-endwise'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-projectionist'
Plug 'tpope/vim-sleuth'
Plug 'tpope/vim-vinegar'
Plug 'tpope/vim-sensible'
Plug 'danwagnerco/tomorrow-theme', {'rtp': 'vim'}
Plug 'zenorocha/dracula-theme', {'rtp': 'vim'}
Plug 'tomasr/molokai'
call plug#end()

" Use colorscheme from package above
colorscheme Tomorrow-Night-Bright

" Settings
syntax on
set relativenumber
set number
set smarttab
set splitbelow
set splitright
set clipboard=unnamed
set laststatus=2
set scrolloff=5
" set textwidth=80
" set colorcolumn=+1
set backupdir=c:\tmp  " Do not clutter directory with swap
set directory=c:\tmp  " and temp files
set noundofile        " as well as undo files
set noerrorbells visualbell t_vb=
let g:netrw_liststyle=3
" set colorcolumn=80
set guifont=Powerline\ Consolas:h10
set encoding=utf-8
let g:airline_powerline_fonts=1

" ConEmu conflict with Vim check out
" Github issue https://github.com/Maximus5/ConEmu/issues/641
inoremap <Char-0x07F> <BS>
nnoremap <Char-0x07F> <BS>

" Specify .md files as markdown
au BufRead,BufNewFile *.md setlocal ft=markdown

" Configure tabstop softtabstop and expand or not by filetype
if has("autocmd")
  filetype on

  autocmd FileType vim setlocal ts=2 sts=2 sw=2 expandtab
  autocmd FileType ruby setlocal ts=2 sts=2 sw=2 expandtab
  autocmd FileType python setlocal ts=4 sts=4 sw=4 expandtab
  autocmd FileType html setlocal ts=2 sts=2 sw=2 expandtab
  autocmd FileType css setlocal ts=2 sts=2 sw=2 expandtab
  autocmd FileType elm setlocal ts=4 sts=4 sw=4 expandtab

  " These highlight lines that extend past 80 chars
  " autocmd BufEnter * highlight OverLength ctermbg=red guibg=#592929
  " autocmd BufEnter * match OverLength /\%>80v.\+/

  " Turn off bells
  autocmd GUIEnter * set visualbell t_vb=

endif

" Leader customization
let mapleader=" "
map <Leader>ptt :Dispatch py.test %<cr>
map <Leader>pta :Dispatch py.test<cr>
map <Leader>rss :Dispatch bundle exec rspec %<cr>
map <Leader>rsa :Dispatch bundle exec rspec ./spec<cr>
map <Leader>c :ccl<cr>
map <Leader>gs :Gstatus<cr>
map <Leader>gc :Gcommit<cr>

@AlexanderBlum
Copy link

hey, thanks for posting that.

I actually gave up and switched from Vundle to vim-plug.

It has been much, much easier to use.

@HardCodeProgrammer
Copy link

HardCodeProgrammer commented Dec 14, 2020

Great but why aren't the images visible ??? @danwagnerco

@danwagnerco
Copy link
Author

Hi @HardCodeProgrammer I strongly recommended switching to vim-plug:

https://github.com/junegunn/vim-plug

The Windows support is smooth and the README documentation is enough to get up-and-running.

Thanks! -Dan

@danwagnerco
Copy link
Author

Now that I look back through this thread @HardCodeProgrammer there is actually a short tutorial on how to set up vim-plug included as a response to Alexander Blum:

https://gist.github.com/danwagnerco/36295f7f92f4bd5506fa#gistcomment-3437945

Thanks! -Dan

@HardCodeProgrammer
Copy link

Now that I look back through this thread @HardCodeProgrammer there is actually a short tutorial on how to set up vim-plug included as a response to Alexander Blum:

https://gist.github.com/danwagnerco/36295f7f92f4bd5506fa#gistcomment-3437945

Thanks! -Dan

Thank you so much for replying

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment