Saturday, July 3, 2010

Find matching parenthesis effectively

Hi folks,

In one of my vim script, I have to determine the line no of opening
parenthesis of a C function.
For example consider the following sample text

int foo(a,
b,
c,
d);
//cursor position.
{
....
}

Let's say the cursor is at position as marked in the above text. I
execute the following code in vim script, it works fine, but it takes
around 6-7 seconds to find the opening parenthesis of a function.

let line=1
while ( line != 0)
let line = searchpair('(', '', ')', 'bW',
'synIDattr(synID(line("."), col("."), 1), "name") =~ "cComment"')
endwhile

I like to know is there any other faster alternative to find the line
no of opening parenthesis of a function in vim script?


Regards,
Kkde

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: