If you use VIM, you’re probably familiar with the incredible % command. It allows you to jump back and forth between opening and closing block operators, for example {} [] ().

Unfortunately, the default doesn’t support HTML, and subsequently RHTML tags.

Thank god for matchit!

From ~/, create a .vim directory (if it doesn’t already exist), and extract matchit.zip.

Matchit should be up and running for a number of additional languages (ADA, HTML, etc). Now we just need to associate RHTML files with the proper type (HTML).

Then in ~/.vim, create a file called

filetype.vim with the following content:

augroup filetypedetect
  au! BufRead,BufNewFile *.rhtml setfiletype xhtml
augroup END</code

You can now place your cursor at the beginning of a <% ... %> block and hit %. Tada! (This also provides the added benefit of HTML snytax highlighting)

UPDATE: The VIM-Ruby project includes matchit definitions for .rb files which allow you to jump between def/end declarations as well!

One response


Do you want to comment?

Comments RSS and TrackBack Identifier URI ?

I use VIM, but I’m more familiar with the infamous; (. )( .) command. It should come as a default upgrade with the ubuntu software package. Check your c:/boobs directory. It allows all the HTML you can throw at it.

November 5, 2005 11:16 pm

Sorry, the comment form is closed at this time.