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
Note: Tim Pope's
pathogen package manager will be installed.
Option 1: Download and run the setup file
wget is installed, then download and run this script using the following in the terminal:
chmod a+x vimsetup.sh
To install R-markdown Vim plugins, make sure that Git is installed.
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.)
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:
Now save the file and exit vim by pressing the
<Esc> key (to enter 'normal' mode) and typing
You should be back in the terminal now.
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
Go to the .vim folder and make directories
mkdir autoload colors plugin
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/
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
cp ~/Downloads/delimitMate-2.7.zip ~/.vim/
Make sure you are in the .vim directory, then unzip delimitMate-2.7.zip.
This will put
delimitMate.vim scripts in the
plugin folders (you need both - they are different!), and will create a
We can now remove the .zip file (it's not needed anymore).
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
vimrc files, but here is a link to read more about it:
Stackoverflow post about Vim persistent undo
Finally, download the vimrc.txt file, and then copy it to/overwrite the
$ cp ~/Downloads/vimrc.txt ~/.vimrc
That's it! Hope you enjoy the colour theme.
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.
Download the zip file vimfolder.zip and:
cp ~/Downloads/vimfolder.zip ~/.vim/
and do Step 5 above (download and move the .vimrc file), and that's it.
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.