Haskellmode Guide: Awesome Haskell with Vim

So you recently started programming in Haskell, because it is awesome, and you have decided that you want to make it all super easy by using your favourite editor, Vim, to do lots of the heavy lifting for you. Then you have come to the right place, this is a guide that will tell you how you can install and use haskellmode in Vim is a few simple steps along with a few of the problems that I had to solve myself along the way. I should note that this tutorial was all done on an install of Ubuntu 10.4 so you should keep that in mind.

Notable Features

The first question that you should have is: what exactly does haskellmode give me in vim and this is a list of some of the features (if you already want to install it and do not need convincing then please skip this section):

  • Function name autocompletion.
  • Auto Function type signiature generation.
  • Easy Function Lookup
  • Automatically imports of required features.
  • Easy importation of language pragmas and compile options.
  • Documentation at your fingertips

These are all explained in more detain by the videos at the end.

Preparing your .vimrc

Before you go installing this plugin we need to make sure that your .vimrc is prepared to give haskellmode all of the data that it needs so please

vim ~/.vimrc

And then add in the following:

" You may already have the following two on, please check
syntax on
filetype plugin on

" This assumes that ghc is in your path, if it is not, or you
" wish to use a specific version of ghc, then please change
" the ghc below to a full path to the correct one
au BufEnter *.hs compiler ghc

" For this section both of these should be set to your
" browser and ghc of choice, I used the following
" two vim lines to get those paths:
" :r!which google-chrome
" :r!which ghc
let g:haddock_browser = "/usr/bin/google-chrome"
let g:ghc = "/usr/bin/ghc"

The really important part here is that you get the haddock_browser and ghc commands right, if they do not point to valid locations then you will have problems.

Downloading and Installing Haskelmode

Now we have come to downloading and installing haskelmode and it could not be more simple:

wget ''
vim haskellmode-20090430.vba

Now that vim is open do the following:

:so %

And that is all that there is to it. How easy was that to install? You now have haskellmode installed properly but you may have one or two errors that you may need to take care of.

Possible Errors and their Solutions

Try and open up a haskell source file (.hs) and if you see some line of text come up on the screen really quickly then it is likely that the documentation cannot be found on your machine and you might want to add the following line to your .vimrc:

let g:haddock_docdir = "/usr/share/doc/ghc6-doc/html/"

The Guide Videos

To fully explain the features of haskellmode for vim some short videos were created here that you should take a look at.


Gnome Terminal: Disable F1 Help

As a user of xMonad, Vim and the gnome-terminal one of the most annoying issues in the world is trying to change window in xMonad, or exit insert mode in vim and find that you have accidentally pressed the F1 key and the gnome-terminal help appears. It is almost like this should be disabled. Well luckily for you it can be, just follow the steps that I found on a bug report of a similar name:

1. Go to a gnome-terminal instance.
2. Edit -> Keyboard Shortcuts
3. Find the one that sets Help to F1.
4. Click on the key binding slot and press backspace.

Problem solved and no annoying popup windows. I hope this helps somebody else too.