[Tutor] multiline comment in Python
Alan Gauld
alan.gauld at blueyonder.co.uk
Sun Sep 21 13:29:50 EDT 2003
> i think the easiest way to do this with vi is using
> block-wise selection. this will comment out the next 10
> lines:
>
> 0[ctrl-v]10jI#
Note that is is not standard vi, its a vim feature.
In vi the way to do blocks is to provide the line numbers
at the start of the command, the numbers can be relative
or absolute:
.,+5<command>
applies command from the current line(.) to the next 5 lines(+5)
15,20<command> applies the command to lines 15 thru 20.
The latter is easiest if you have line numbering switched on.
But you can also use searches to define the block:
:+3,/foo/<command>
applies command to the block starting 3 lines down and extending
to the next line containing 'foo'.
To create comment lines I usually use the substitute command:
:.,/foo/s/^/#/
This substitutes the start of a line(^) with a #
:.,/foo/s/^#//
removes it again.
Alan G.
More information about the Tutor
mailing list