Hi,
>Hi all,
>
>I have this regexp that I wrote which will match on the specific C/C++
>function I am looking for right up to the first open brace. What I
>want to do is grab everything between the first open brace and the last
>close brace for that function { }. Effectively I want my regexp to
>grab a specific C function in it's entirety.
>
>So far my regexp looks like this:
>s/\s*\(.*\)\s*\*\(.*\)::recv\s*(\s*int\s*\*\s*\(.*\))\s*\n*\s*\(.*\)\s*\n*\s*{
>and what it does is it grabs the beginning of any function that
>matches: foo* bar::recv(int* foobar) {.
>
>I want to take it all the way to the end of the function (could be up
>to 50 or so lines) so that it matches on foo* bar::recv(int* foobar)
>{ ... }. Is this at all possible? My ultimate goal is to find and
>remove a certain function in many different files. Any
>suggestions/advice is welcome.
>
>Thanks, Justin
as far as i know there is no clever way to count braces with regexp. So
you would have to use the indent to identify the correct closing brace.
Say your function is indentend by 4 spaces you could you:
g/\s\{4\}foo.*bar::recv.*{/,/^\s\{4\}}/d
With selects every code block indented by 4 spaces followed by foo*
bar::recv * { until it hits a closing brace indented by 4 spaces. If you
have to apply this change to many files i would suggest sed.
Kind regards
Chris
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---