Now I have a text file that looks like this:
{
int fun(int a, int b // match begin this line
int c) {
if (a == 0) {
a = 1;
} else {
a = -1;
}
return 0;
} // mathc end this line
}
{
int funNoMatch(int a, int b
int c) {
return 0;
}
}
How can I use vim regex to match the entire fun() function in vim?
I can use the following regex to match lines until the left brace of the fun() function:
/^ int fun\_[^{]*{
But... I cannot match lines until the right brace of the fun() function.
I can also use "\_"
, but it cannot work in this situation.
I want only the fun() function to be matched and do NOT want funNoMatch to be matched.
And I want to match them in Vim by vim regex.
Can anyone can help me?
NOTE:
You can assume the beginning and end of the function have the same indent level.
some good friends have given me some other method to solve my problem and thanks, but I also want to know whether the RegEx can do the same thing or not by the same indent level