Indent or comment several text lines with VI

Posted by Werner on Stack Overflow See other posts from Stack Overflow or by Werner
Published on 2010-03-17T14:02:41Z Indexed on 2010/03/17 14:11 UTC
Read the original article Hit count: 264

Filed under:

Hi,

can vim or vim be used to comment or indent at the same time a number of lines? For instance:

for item in Lista:
    ind = int(floor(1.0*(item-lmin)/width))
    if ind==nintervals:
        ind=ind-1
    print item,ind

comment it to:

#for item in Lista:
    #ind = int(floor(1.0*(item-lmin)/width))
    #if ind==nintervals:
        #ind=ind-1
    #print item,ind

or indent it to:

  for item in Lista:
      ind = int(floor(1.0*(item-lmin)/width))
      if ind==nintervals:
          ind=ind-1
      print item,ind

Thanks

P.D. Is relevant the difference between VI and VIM?

© Stack Overflow or respective owner

Related posts about vim