[Haskell-cafe] UPDATE: haskellmode for Vim now at projects.haskell.org (+screencast; -)

Claus Reinke claus.reinke at talk21.com
Tue Apr 7 05:23:21 EDT 2009

I have become aware that many Haskellers are not aware of the
Haskell mode plugins for Vim, in spite of the >100 downloads
per month I saw when I last checked. Since the plugins have just
completed their move to their new home at


this seems to be a good opportunity to mention them again (now
with 100% more screencasts!-). They do much (though certainly
not all) of the stuff people often wish for here, such as showing or 
adding types, looking up source where available locally or looking 
up documentation where source isn't available. Mostly, they collect
my attempts to automate tasks when I have to do them often enough.

Here is a section of the quick reference (:help haskellmode-quickref):

    |:make|               load into GHCi, show errors (|quickfix| |:copen|)
    |_ct|                 create |tags| file 
    |_si|                 show info for id under cursor
    |_t|                  show type for id under cursor
    |_T|                  insert type declaration for id under cursor
    |balloon|             show type for id under mouse pointer
    |_?|                  browse Haddock entry for id under cursor
    |:IDoc| {identifier}  browse Haddock entry for unqualified {identifier}
    |:MDoc| {module}      browse Haddock entry for {module}
    |:FlagReference| {s}  browse Users Guide Flag Reference for section {s}
    |_.|                  qualify unqualified id under cursor
    |_i|                  add 'import <module>(<identifier>)' for id under cursor
    |_im|                 add 'import <module>' for id under cursor
    |_iq|                 add 'import qualified <module>(<identifier>)' for id under cursor
    |_iqm|                add 'import qualified <module>' for id under cursor
    |_ie|                 make imports explit for import statement under cursor
    |_opt|                add OPTIONS_GHC pragma
    |_lang|               add LANGUAGE pragma
    |i_CTRL-X_CTRL-O|     insert-mode completion based on imported ids (|haskellmode-XO|)
    |i_CTRL-X_CTRL-U|     insert-mode completion based on documented ids (|haskellmode-XU|)
    |i_CTRL-N|            insert-mode completion based on imported sources
    |:GHCi|{command/expr} run GHCi command/expr in current module

For those who have never used these plugins, or haven't used Vim
at all, it has often been difficult to imagine what editing in Vim can
be like. The old quick tour of features available has now been updated
from screenshots to screencasts (my first venture into this area - please 
let me know whether that is useful or a waste of time!-), so you can 
watch them on Youtube before deciding to invest time into learning Vim.

For those who are using Vim, the only reason not to use my 
haskellmode plugins would be if you had your own (not uncommon
among Vim users;-), in which case I hope you make yours available 
as well (feel free to adopt features from my plugins, and let me know
if you have some useful features to contribute), here:


For those who have happily been using these plugins: in the process
of moving the site, I noticed that I hadn't updated the published
version for a quite some time - apparently, noone had missed the 
fixes, but in case you want to check, the relevant section of my update
log is appended below.

Happy Vimming!-)

------------- updates since last published version on old site
  haskell_doc.vim: when narrowing choices by qualifier for _?, take
                     lookup index from un-narrowed list (else we could
                     end up in the docs for the wrong module)

  ghc.vim: actually, we can try to make a reasonable guess at the parent
            type for constructors in _ie, from their type signature

  ghc.vim: try a bit harder to escape " and ' in :GHCi
           eliminate duplicates in _ie and mark data constructor imports
             as ???(Cons) - we can't reliably figure out the parent type
             for the constructor:-(
           handle Prelude as special case in _ie (can't just comment out
             import, need to import [qualified] Prelude [as X]() )

  haskell_doc.vim: fix keys (no namespace tags) and urls (modules) for :MDoc

  all files: new home page at projects.haskell.org

  haskell_doc.vim: in ProcessHaddockIndexes2, fix a case where making new entries
                    could lose old ones (eg, zipWith's base package locations got
                    lost when adding its vector package locations) 

  haskell_doc.vim: since we're now reading from multiple haddock indices in
                    DocIndex, we need to extend, not overwrite entries..

  ghc.vim: do not reset b:ghc_static_options on every reload

More information about the Haskell-Cafe mailing list