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

Re: delete last character of multiple lines

Expand Messages
  • yoni kessler
    thanks allot! I m a bit familiar with regex, but can you please explain what exactly does :
    Message 1 of 10 , May 8, 2013
    • 0 Attachment
      thanks allot!

      I'm a bit familiar with regex,
      but can you please explain what exactly does :'<,'> means?

      thanks again

      --
      --
      You received this message from the "vim_use" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php

      ---
      You received this message because you are subscribed to the Google Groups "vim_use" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Nicolas Dermine
      ... Hi Yoni, The
      Message 2 of 10 , May 8, 2013
      • 0 Attachment



        On Thu, May 9, 2013 at 12:44 AM, yoni kessler <yoni101kessler@...> wrote:
        thanks allot!

        I'm a bit familiar with regex,
        but can you please explain what exactly does   :'<,'>  means?

        Hi Yoni,

        The '<,'> range stands for the current (or last) visual selection.

        When you have a visual selection and type :, the command line automatically gets this '<,'> range avec the colon.

        If you wanted to apply the search and replace command on the whole file, you would use % to specify the range of the s/.$ command :

        :%s/.$

        To do that only on the last/current visual selection :

        :'<,'>s/.$

        To do that on lines 2 to 4 :

        :2,4s/.$

        If you type :helpgrep '<,'> (and then :cn to navigate to the next occurrences found in the documentation) you can read more about it.
        For example this in usr_10.txt :

        ```
        The '< and '> are actually marks, placed at the start and end of the Visual
        selection.  The marks remain at their position until another Visual selection
        is made.  Thus you can use the "'<" command to jump to position where the
        Visual area started.  And you can mix the marks with other items: >

        :'>,$

        This addresses the lines from the end of the Visual area to the end of the
        file.
        ```

        nico






        thanks again

        --
        --
        You received this message from the "vim_use" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php

        ---
        You received this message because you are subscribed to the Google Groups "vim_use" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.



        --
        --
        You received this message from the "vim_use" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php
         
        ---
        You received this message because you are subscribed to the Google Groups "vim_use" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
         
         
      • Tim Chase
        ... That s a range as defined by two marks, the
        Message 3 of 10 , May 8, 2013
        • 0 Attachment
          > but can you please explain what exactly does :'<,'> means?

          That's a range as defined by two marks, the

          '<

          mark (meaning the starting line of a visual selection)

          ,

          through the

          '>

          mark (meaning the ending line of a visual selection).

          Vim supports an incredibly powerful declaration of ranges which you
          can read about at

          :help :range

          which allows for absolute and relative addressing, including relative
          to previous addresses such as

          :1/CHAPTER/+2,$?APPENDIX?-3

          which starts on line 1, searches forward for "CHAPTER", then moves
          forward 2 lines from there to start the range, and then starts at the
          bottom of the file ("$"), searches backwards for "APPENDIX", and then
          moves 3 lines back from that match.

          -tim



          --
          --
          You received this message from the "vim_use" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php

          ---
          You received this message because you are subscribed to the Google Groups "vim_use" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.
        • James
          ... Hi Yoni, I m not a regex expert. I usually do that sort of thing with a macro. qq // start recording macro q $ // move cursor to end
          Message 4 of 10 , May 9, 2013
          • 0 Attachment
            On May 8, 10:01 am, yoni kessler <yoni101kess...@...> wrote:
            >
            > I tried to delete the last character of multiple lines in the following way:

            Hi Yoni,

            I'm not a regex expert. I usually do that sort of thing with a macro.

            qq // start recording macro 'q'
            $ // move cursor to end of current line
            x // delete character
            j // move down to next line
            q // stop recording macro

            Now you can delete the last character of ten lines starting at the
            line containing the cursor with the following command.

            10@q

            James

            --
            --
            You received this message from the "vim_use" maillist.
            Do not top-post! Type your reply below the text you are replying to.
            For more information, visit http://www.vim.org/maillist.php

            ---
            You received this message because you are subscribed to the Google Groups "vim_use" group.
            To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
            For more options, visit https://groups.google.com/groups/opt_out.
          Your message has been successfully submitted and would be delivered to recipients shortly.