Gherkin Highlighting for VIM

Monday, June 21st, 2010

I really wanted some highlighting on my .feature files in vim, I’m no vim expert so I did a bit of googling and came up with the following:

  • Download cucumber.vim from http://github.com/tpope/vim-cucumber/blob/master/syntax/cucumber.vim
  • Save the file to ~/.vim/cucumber.vim (creating the directory if required)
  • vim ~/.vimrc and add the following lines

    au Bufread,BufNewFile *.feature set filetype=gherkin
    au! Syntax gherkin source ~/.vim/cucumber.vim
  • Make sure
    syntax on

    is also present

  • Open your feature file

If anyone knows a more vim way of doing this feel free to add a comment.

Tags: , , , , ,

4 Comments to Gherkin Highlighting for VIM

Mehul
July 1, 2010

That is a really neat feaature. Custom highlighting in VIM based on the file type. I didnt know you could do that.

I should look for some of these to make viewing XML files easier to read.

Richard Paul
July 3, 2010

Vim usually comes with XML syntax highlighting by default, you might need to turn syntax highlighting to auto to have it automatically picked up.

Petri
August 9, 2010

I can’t get this to work. I downloaded cucumber.vim, put it in /home/myacct/.vim/, added those lines in /home/myacct/.vimrc, but nothing happened.

Richard Paul
August 9, 2010

Hmmm, sorry Petri, all I can say is ‘it works on my machine’.

Leave a comment