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

easy alignment

Expand Messages
  • V.Chandrasekaran
    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
    Message 1 of 3 , Apr 3, 2005
    • 0 Attachment
      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.
    • A. J. Mechelynck
      ... 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
      Message 2 of 3 , Apr 3, 2005
      • 0 Attachment
        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.
      • A. J. Mechelynck
        ... Oops -- I forgot a backslash before the { -- see :help /multi Best regards, Tony.
        Message 3 of 3 , 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.
        Your message has been successfully submitted and would be delivered to recipients shortly.