Vi commenting out
Michael Hipp
Michael
Mon Oct 16 19:27:59 PDT 2006
Bill Campbell wrote:
> On Mon, Oct 16, 2006, Michael Hipp wrote:
>> Is there any simple trick for having vi comment out a whole range of lines by
>> placing a '#' in front of them? The manual method of i # ESC j is rather
>> tedious if there is a big section to be done.
>
> Position the cursor on the top line you want to comment. Press
> ``ma'' (Mark A) to set a mark there.
>
> Position the cursor at the bottom of the range. Enter this
> command which says to operate over the range from the marked a to
> the current line ('a indicates the mark a, `b would be mark b).
>
> :'a,.s/^/#/<RETURN>
>
> One could also do ``I#<ESC>'' then press ``j.'' to go down a line
> and repeat the previous command for as many lines as you like.
Thanks, Bill. One or the other should do the job depending on how long the
section may be.
Michael
More information about the Linux-users
mailing list