Adventures with Ruby

Plain Text Stories and Vim

View Comments

Update: Updated the syntax file, redownload it if you got it before December 19th 2007.

More news about my adventures with Selenium. It’s hot and juicy, so lot’s of exciting new things to do. I made a syntax highlighter for plain text stories in vim. Here’s how it looks:

An example of vim with plain text story highlighting

To make it look like this, I adjusted the slate colorscheme and added my own story syntax file. Click Continue Reading to download the files and read how to install it.

Here is what you need to do:

  1. Put the black-slate colorscheme file in /usr/share/vim/vim71/colors directory
  2. Put the story syntax file in /usr/share/vim/vim71/syntax directory
  3. Append these lines to the end of /usr/share/vim/vim71/scripts.vim:
    if did_filetype()
      finish
    endif
    if getline(1) =~ "^Story:\s.*"
      setf story
    endif
  4. Add these lines to your personal vimrc (~/.vimrc) or the systemwide vimrc file (/etc/vim/vimrc):
    set background=dark
    set tabstop=2   "please default all tabs to 2 spaces
    set shiftwidth=2
    set expandtab
    set number
    set smartindent
    set smarttab
    filetype plugin on
    filetype indent on
    colorscheme black-slate
  5. Type your plain text stories, make sure every story file starts with ‘Story:’
    It won’t recognize it’s a plain text story right away, so first type ‘Story:’, save it and reopen it to get nice colours.

By the way, Arie has made a syntax highlighter for the google javascript syntax highlighter. Keep a look out on his blog too!

Caution: WordPress changes the quotes. In step 3 you’ll need normal quotes, not backticks.

Written by Iain Hecker

December 18th, 2007 at 2:46 pm

Posted in Uncategorized

  • http://ariekanarie.nl Arie

    Note that at step3 the ` are actually ‘ ;)

  • http://ariekanarie.nl Arie

    Note that at step3 the ` are actually ‘ ;)

  • http://ariekanarie.nl/archives/115/syntax-highlighting-for-plain-text-user-stories Arie’s blog » Blog Archive » Syntax highlighting for plain text user stories

    [...] friend Iain was busy making syntax highlighting in VIm for rSpec’s plain text user stories. I thought it would be nice to modify the Google Syntax Highlighting plugin for WordPress, so you [...]

blog comments powered by Disqus
Fork me on GitHub