I am using Vim 8.0.

I often pepper my Haskell code with undefined stub functions to be filled in later. Note that undefined is a valid keyword in Haskell

add :: Int -> Int -> Int
add a b = undefined

What I'd like to do, while in Haskell mode, is to make the word undefined word look like an eye-sore to remind me that implementations are still not complete.

In particular, I would like the background of undefined to be pink and the foreground color of the text to be, say, black

How do I go about doing this?

1 Answer 1


You can use matchadd() function like this. First define your custom highlighting color:

:hi CustomPink ctermbg=205 guibg=hotpink guifg=black ctermfg=black

Then you can color your words like this:

:call matchadd('CustomPink', '\<undefined\>')

The advantage of using the match functionality is, that this does not depend on the priorities of the defined syntax definitions and is usually more flexible.

Of course, one could create a simple plugin, that defines the colors, highlightes customs words and does some error checking (as well as remembering the id for each match, so it can easily be reverted). But that is out of the scope for my answer for now :)

  • Wow! Thanks. This works nicely. How do I enable this only for files with extension '.hs' though? Otherwise the word "undefined" will appear in pink for all other file-types too. Jul 27, 2017 at 2:55
  • What filetype is '.hs'? Jul 27, 2017 at 20:10
  • Haskell source code files. Jul 29, 2017 at 15:12
  • au FileType haskell :call matchadd('CustomPink' '\<undefined\>') should do it. Jul 29, 2017 at 16:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.