Home Blog CV Projects Patterns Notes Book Colophon Search

Vim Setup

19 May, 2007

About a year ago I was first introduced to Vim by Olly Cope and others at the Institute of Child Health. I borrowed the O'Reilly book and started learning it. Here is the setup I currently have in my ~/.vimrc file.

" Set colour scheme.
color wombat
" Set syntax hilighting
syntax on
" Replace tabs with spaces.
" With this option set, if you want to enter a real tab character use Ctrl-V key sequence.
set expandtab
" Set the number of space characters that will be inserted when the tab key is pressed.
set tabstop=4
" To replace the existing tab characters to spaces
" Set the number of space characters inserted for indentation.
set shiftwidth=4
" Highlight all the search pattern matches.
" To disable the highlighting temporarily - set nohlsearch
set hlsearch
" Set the foreground and background colours
hi Search guifg=slategrey guibg=khaki
" Set line numbers
set number
" Set copy and pasting mode for terminals
set paste

The last command, set paste is particularly useful because it allows you to paste text directly into Vim running in a terminal and Vim correctly maintains the formatting.

You'll notice I've set the color to use wombat. This is a special colour scheme which you have to download and install manually.

mkdir ~/.vim
mkdir ~/.vim/colors
wget http://www.vim.org/scripts/download_script.php?src_id=6657 -O ~/.vim/colors/wombat.vim

If you don't want to use wombat, pablo is another scheme I quite like and it comes with Vim.

The version of Vim which comes with most Linux operating systems isn't the full one so if you are looking to use Vim as your main editor you probably want to install the full version which includes gvim, the X windows version of Vim which integrates with Gnome:

sudo apt-get install vim-full

I honestly wouldn't recommend Vim to people looking for an editor because although I now find it quick, the length of time I have spent not finding it very quick has meant that arguably it wasn't worth the investment of time.

Copyright James Gardner 1996-2020 All Rights Reserved. Admin.