A vimrc file allows Vim to start with some additional features loaded. There are many, many options to customise Vim's appearance, such as in this vimrc file. However, only a few lines are needed in a vimrc file in order to make a huge difference. This post contains a minimal vimrc file, along with an explanation of the commands.

Here is the minimal vimrc file in a txt file: vimmin.txt

Creating a vimrc file

Whether you are working on your personal laptop, or as a user on a server, your vimrc file will be located in the same place: ~/.vimrc. Check what is in this file (it may be empty) by opening it in Vim. In a command line,

vim ~/.vimrc

Note the . before the vimrc. There is no file extension.

Contents of a minimal vimrc file

Copy/paste the following into ~/.vimrc:

syn on
set number
set tabstop=4 expandtab shiftwidth=4 smarttab
set autoindent cindent
colo pablo

Or download using:

#save current location
mkdir -p ~/build/vim
cd ~/build/vim
if [ -f "~/.vimrc" ]; then cp ~/.vimrc ./bak_vimrc.txt; fi
wget www.deanbodenham.com/downloads/vimmin.txt
cp ./vimmin.txt ~/.vimrc
cd "$currentdir"

The commands explained

syn on

Probably the most useful command, syn on turns on syntax highlighting. So, keywords in different programming language scripts (.cpp for C++, .R for R, .py for Python, etc) will appear in different colours, making the code more readable. Exactly what these colours are (the colour theme) will be set by the colo command later.

set number

This command makes line numbers appear on the left-hand side of the vim screen. This is useful, because the command (in Normal normal):

:25 (Enter)

will move the cursor to line 25, for example.

set tabstop=4 expandtab shiftwidth=4 smarttab

The most difficult command to remember, this is actually four separate commands that affect the tabbing behaviour. Check out this page in the Vim wiki for more information.

set autoindent cindent

These two commands enable automatic indenting in different programming language scripts (.cpp for C++, .R for R, .py for Python, etc). Check out this page in the Vim wiki (scroll down a bit to 'Methods for automatic indentation') for more information.

It is also possible to add smartindent to the line, but this can lead to annoying behaviour in R scripts. In fact, when comments are made in R using #, this forces the comment to be left aligned. This can also be annoying, but is fixed in this vimrc file.

colo pablo

This line sets the colorscheme, and is the most personal choice. In order to see the different colorschemes available, open a file in Vim and then type

:colo (SPACE + TAB)

to run through the different colorschemes. Eventually, when you see one that looks interesting, e.g.

:colo elflord

Press Enter to see what how that colorscheme changes the file's appearance. Note that if you leave out the space, and press tab after :colo, this will complete to


This is fine, because colo is just shorthand for colorscheme (but it worthwhile being aware of this). Another colorscheme I like is murphy, so the line in the vimrc file could also be:

:colorscheme murphy

There should be several default colorschemes available with your Vim installation (and will usually be available with most installations), so have a look at them to find a go-to colorscheme you like. However, if you want to use a custom colorscheme, this is possible, but just requires a few minutes more effort. See this post for more information on setting up a custom colorscheme.


This post has grown longer than intended. The take-home message is to know (remember) these five commands, so that if you end up using a machine without a Vimrc, you'll be able to get up and running with a few Vim luxuries in under a minute.