How to select multiple lines
Philippe Poilbarbe
Philippe.Poilbarbe at cls.fr
Tue Sep 8 10:48:48 CEST 2009
Thomas Orgis a écrit :
> Am Tue, 08 Sep 2009 09:14:07 +0200
> schrieb Eric Bouyoux <eric.bouyoux at insidefr.com>:
>
>
>> Hi,
>>
>> The title is not very explicit. Let's have an example.
>> My file contains :
>> module toto ;
>> ... (1000 lines of code)
>> endmodule
>>
>> I want to remove all lines between "module toto" and "endmodule".
>> One possibility is to select all lines between the 2 keywords and to
>> remove them. But how can I do this automaticaly ?
>>
>
> Interesting point. I am not sure how many other Fortran programmers are here... there is an equivalent task in C-style languages, the operation to got to a machting bracket/brace/parentheses:
>
> function bla()
> {
> (100 lines of code)
> }
>
> ...
>
There is no kind of braces to delimit blocs in fortran. It is done by
keywords or by lines.
You can do what you want
Replace the function by nothing. The replacement done by using regular
expressions.
Put the RE "module\s+toto(?n.*?)endmodule" (without quotes) in the
"string to find" box and nothing in the "replace with" box and click on
"Regular expression".
The (?n) construct instruct the search process to include the newline in
the characters matched by '.'.
The '?' character is there to stop on the first 'endmodule' encountered
(for the case there is more than one module in the file).
To be sure you take the whole lines you can enhance the RE with this
(but not very readable :) ):
^\s*module\s+toto(?n.*?)\n\s*end\s*module\s*$
This take also the spaces before 'module' and the ones after 'endmodule'
(end maybe some between 'end' and 'module')
More information about the Discuss
mailing list