[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Vim question



Paolo Pantaleo wrote:
> I just started learning python (i think it is great). Now i have the
> following problem:
> How can i comment 10 lines of code in a shot? That is, how can i add a
> # at the begenning of a range of lines?
> 
> just to be more clear, i want to rasform
> 
> a=['a','b','c']
> for i in a:
>     do_something(i)
>     print i
> 
> to
> 
> #a=['a','b','c']
> #for i in a:
> #    do_something(i)
> #    print i
> 
> Thnx
> PAolo
> --
> 
There are many ways to accomplish this.  Here's one way.  Assuming you
have the following line numbers (turn on line numbering with :set nu)

10 a=['a','b','c']
11 for i in a:
12     do_something(i)
13     print i

Now type
:10,13s/^/#/g

That should do it.  Basically, you're looking for the beginning of each
line (^) from 10 to 13.  Then you're inserting a # in each spot.

HTH
Eric



Reply to: