tags:

views:

61

answers:

1

Hi there,

I am at present writing a syntax file in VIM for the script language I use, which isn't a generic language like c.

One of the block syntaxes is the do..loop structure as below:

DO
    blah blah blah
LOOP times, label

I wonder that if there is a way for me to make the cursor go back and forth around DO and LOOP like in c I press % then the cursor moves during "{" and "}".

Thanks a lot.

+1  A: 

You can use the matchit plugin to define additional pairs of block start and end keywords to jump to with %. For your case something like

:let b:match_words = '\<DO\>:\<LOOP\>'

should work. To keep your setup tidy you should define this in an new filetype plugin. The matchit documentation has an extra chapter |matchit-newlang| devoted to this topic.

honk
Thank you very much for the hint, I will try it. But i want to know that whether it is related with syntax file? In another word, how could c make sense even without the matchit plugin?
stefanzweig
There are some built-in defaults http://vimdoc.sourceforge.net/htmldoc/motion.html#%
honk