This post provides instructions for how to set up Vim with the wombat colour scheme in iTerm, and my personal preference for setting up Vim.

For a basic setup with a minimal vimrc, see this previous post, otherwise read on.

Quick downloads: vimrc.txt and wombat17.vim

It is advised that Vim is installed properly on OSX or Linux with the +clipboard option. See this post for installing Vim in OSX and this post for installing Vim in Linux.

Note: Tim Pope's pathogen package manager will be installed.

Automatic setup

Option 1: Download and run the setup file

In order to use this option, make sure you have the wget tool installed and git. See this post for installing wget on OSX. For installing git, see this post.

If wget is installed, then download and run this script using the following in the terminal:

wget www.deanbodenham.com/downloads/vimsetup.sh
chmod a+x vimsetup.sh
./vimsetup.sh
rm vimsetup.sh

To install R-markdown Vim plugins, make sure that Git is installed.

Basic

Here is a really basic setup.

In iTerm, or your favourite terminal emulator, create a basic .vimrc file by typing:
(don't type the $, that denotes the command prompt. If you copy/paste the commands below, the $ won't be copied.)

vim ~/.vimrc 

This will open the .vimrc file in Vim. The ~/ is the path to your 'home' directory. If this is the first time you are using Vim, the chances are that this file will be blank. In which case, in Vim press the i key to switch to 'insert' mode, and type the following two lines:

syn on
set number

Now save the file and exit vim by pressing the <Esc> key (to enter 'normal' mode) and typing

:wq 

You should be back in the terminal now.

Manual instructions
Step 1:

To set things up step by step, without using pathogen, follow the instructions below. This is the way I used to do it, but now I prefer to use the setup file above.

In the terminal, create the .vim folder by typing

mkdir ~/.vim

Step 2:

Go to the .vim folder and make directories autoload, colors and plugin:

cd ~/.vim
mkdir autoload colors plugin

Step 3:

Download the wombat15.vim colour theme file.
(suppose it is saved to the directory ~/Downloads, and make sure it has the '.vim' extension - sometimes a browser will replace '.vim' with '.bin'.)

Now copy this file to the vim colors directory:

cp ~/Downloads/wombat15.vim ~/.vim/colors/

If you like, you can do the same thing for the the wombatalt.vim colour theme file, which is basically the same as the original wombat.vim.

Step 4:

In this step we shall download a Vim script which provides automatic closing of brackets, quotes, etc., which is useful when writing code. There are several options out there, but I found delimitMate to be the best.

Download delimitMate-2.7.zip from here (again, suppose it is saved to the directory ~/Downloads). Now copy it to the ~/.vim directory,

cp ~/Downloads/delimitMate-2.7.zip ~/.vim/

Make sure you are in the .vim directory, then unzip delimitMate-2.7.zip.

cd ~/.vim
unzip delimitMate-2.7.zip 

This will put delimitMate.vim scripts in the autoload and plugin folders (you need both - they are different!), and will create a doc folder.

We can now remove the .zip file (it's not needed anymore).

rm delimitMate-2.7.zip 

Step 5:

A nice feature is to set Vim to have persistent undo, i.e. if the file is closed and then re-opened, you can still undo changes from the previous session. This is configured automatically in the vimsetup.sh and vimrc files, but here is a link to read more about it: Stackoverflow post about Vim persistent undo

Step 6:

Finally, download the vimrc.txt file, and then copy it to/overwrite the ~/.vimrc file.

 $ cp ~/Downloads/vimrc.txt ~/.vimrc 

That's it! Hope you enjoy the colour theme.

Background

Recently I started using Vim again while working on a project that required me to code in R, C++, Python and Bash simulataneously (what was I thinking...), and it made me wonder why I'd ever left. The first step was to sort out my .vimrc file, which took some experimentation (which script gives the best parenthesis completion?). The next step for me was to find a nice colour scheme, and for a while I was very happy with solarized.

However, for some reason solarized was not straightforward to set up with iTerm (what eventually worked me for me was the line 'set t_Co=256' in my .vimrc). Then, when I tried to use solarized with terminator on my Linux machine, the colours appeared to be a bit different. Finally, when I switched back to Eclipse for older projects, the colours were different again (by the way, Vim keybindings with vrapper are awesome - check out the Eclipse marketplace). Yes, I probably care too much.

Anyway, I really started to like the wombat colour theme that one can get with the Eclipse colour themes add-on, but could not get the original script to work with iTerm. This led me to the wombat256mod script, which did work, but was not quite the same as the Eclipse version. Finally, a vimcast by Drew Neil, this entry on Andrew Radev's site and this page showed me how to modify the colour theme to make it appear as I desired, and add my own 'syntax groups'. For example, I wanted to make '$' appear in a different colour (this may be useful for R users who use data frames a lot). The above was an attempt to provide instructions, mainly to my future self, for setting up my .vimrc and installing the colour theme, which I have named wombat15.

The first few steps (in 'Basic') are very easy, but I thought it was worth being explicit since the instructions are meant for someone who is completely new to Vim. I've recently come across blogs which give instructions for 'simple' things which have taken me a few Google searches to figure out how to do.


Express setup

Download the zip file vimfolder.zip and:

cp ~/Downloads/vimfolder.zip ~/.vim/
cd ~/.vim
unzip vimfolder.zip
rm vimfolder.zip

and do Step 5 above (download and move the .vimrc file), and that's it.



Credits

Thanks to RPM for checking an earlier version of these instructions.

The wombat colour scheme was originally created by Lars H. Neilsen, and the Eclipse version was made by Roger Dudler. The different .vimrc lines were largely obtained from reading Stackoverflow posts.

making a .vimrc file