Loading ...
Sorry, an error occurred while loading the content.

57839Re: [2] easy alignment

Expand Messages
  • A. J. Mechelynck
    Apr 3, 2005
    • 0 Attachment
      A. J. Mechelynck wrote:
      > V.Chandrasekaran wrote:
      >
      >> Hi,
      >> I have a bunch of lines like below completely misaligned:
      >>
      >> abc
      >> def
      >> ghi
      >>
      >> I want to quickly align the starting position of these 3 lines at
      >> say, column
      >> number 30. Can I record a macro using the internal 'current column
      >> number'
      >> variable and the constant '30' to do this ?
      >>
      >> thanks,
      >> chandra.
      >>
      >>
      > You can do it with a substitute command, as follows:
      >
      > 1. visually select the lines you want to change (move the cursor to the
      > first one, hit Shift-v, move the cursor to the last one).
      > 2. Hit the colon key. ":'<,'>" appears (without the quotes) on the
      > command-line.
      > 3. Complete the command line as follows (untested):
      >
      > :'<,'>s/^\s*/ {29}/
      >
      > which means: In the visually selected lines ('<,'>), replace spaces and
      > tabs (\s) at the left margin (^), zero or more of them but as many as
      > possible (*) with 29 spaces ( {29}). Then press Enter on your
      > command-line to make the substitution.
      >
      > HTH,
      > Tony.
      >
      >
      >
      >
      Oops -- I forgot a backslash before the { -- see ":help /multi"

      Best regards,
      Tony.
    • Show all 3 messages in this topic