goto statement

jfouhy at paradise.net.nz jfouhy at paradise.net.nz
Tue Apr 26 18:59:18 EDT 2005


Maxim Kasimov wrote:
> > Maxim Kasimov <kasimov at i.com.ua> writes:
> >>WOW, just greate! ... but i'd like to relax at some more
> >>interesting way than to comment each of rows
> but what if i just can't to do this becouse i'm working thrue ssh,
and have to
> use only installed editors (such as vi)

A slightly less arcane way of commenting out multiple lines in vi:

To comment out the current line, and the next 5:

:,+5s/^/#/

explanation:

:x,y -- specifies a line range.  If x is omitted, start with the
current line.  If y is +z, interpret it as z lines below the current
line.

^ -- regular expression matching the start of the line.

s/foo/bar/  -- replace foo with bar.

so s/^/#/ replaces the start of the line with the # character.

You can undo this with :,+5s/^#// which replaces a # at the start of
the line with the empty string (ie: deletes it).

HTH.

-- 
John.




More information about the Python-list mailing list