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

moving matched search pattern to after current line

Expand Messages
  • hackware
    I wish to issue a colon command to move a seeded search match to after current line. ... a and b are set and around search area containing the ZZZ seeded
    Message 1 of 4 , Feb 22, 2013
    • 0 Attachment
      I wish to issue a colon command to move a "seeded" search match to after current line.

      like the following:

      :'a,'bg/ZZZ/m.+1

      'a and 'b are set and around search area containing the "ZZZ" seeded line to be moved...

      m is for move, and i had thought the period would mean current line, but it does not...

      and the "+1" would be line after where cursor was before the colon command...

      Seems simple, what am I doing wrong...?

      william...

      --
      --
      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.
    • Ben Fritz
      ... The :g command works by finding a list of lines matching the pattern, setting the current line and executing the command on each of the matched lines in
      Message 2 of 4 , Feb 22, 2013
      • 0 Attachment
        On Friday, February 22, 2013 12:18:50 PM UTC-6, hackware wrote:
        > I wish to issue a colon command to move a "seeded" search match to after current line.
        >
        > like the following:
        >
        > :'a,'bg/ZZZ/m.+1
        >
        > 'a and 'b are set and around search area containing the "ZZZ" seeded line to be moved...
        >
        > m is for move, and i had thought the period would mean current line, but it does not...
        >
        > and the "+1" would be line after where cursor was before the colon command...
        >
        > Seems simple, what am I doing wrong...?
        >
        > william...

        The :g command works by finding a list of lines matching the pattern, setting the "current" line and executing the command on each of the matched lines in turn.

        So . in a :g command refers to each line acted on.

        For simplicity, I will assume you're moving lines to a position outside of your 'a,'b range. You could either give an absolute number directly, or use :exec 'g...'.line('.'), or set a mark on the current line and use that.

        --
        --
        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.
      • hackware
        ... ahhh... backasswards b my normal problem... did not realize that :g set current line... guess i ll have to figger out yank/put from registers... (working
        Message 3 of 4 , Feb 22, 2013
        • 0 Attachment
          On Friday, February 22, 2013 3:00:49 PM UTC-6, Ben Fritz wrote:
          > On Friday, February 22, 2013 12:18:50 PM UTC-6, hackware wrote:
          > > I wish to issue a colon command to move a "seeded" search match to after current line.
          > >
          > > like the following:
          > >
          > > :'a,'bg/ZZZ/m.+1
          > >
          > > 'a and 'b are set and around search area containing the "ZZZ" seeded line to be moved...
          > >
          > > m is for move, and i had thought the period would mean current line, but it does not...
          > >
          > > and the "+1" would be line after where cursor was before the colon command...
          > >
          > > Seems simple, what am I doing wrong...?
          > >
          > > william...
          >
          > The :g command works by finding a list of lines matching the pattern, setting the "current" line and executing the command on each of the matched lines in turn.
          >
          > So . in a :g command refers to each line acted on.
          >
          > For simplicity, I will assume you're moving lines to a position outside of your 'a,'b range. You could either give an absolute number directly, or use :exec 'g...'.line('.'), or set a mark on the current line and use that.

          ahhh...

          backasswards b my "normal" problem...

          did not realize that :g set current line...

          guess i'll have to figger out yank/put from registers...
          (working up to writing a script...)

          thanx...

          william...

          --
          --
          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
          ... As Ben suggests, you can do something like ... where kq drops the q mark on the current/initial line, allowing it to then be referenced as the target
          Message 4 of 4 , Feb 22, 2013
          • 0 Attachment
            On 2013-02-22 13:59, hackware wrote:
            > On Friday, February 22, 2013 3:00:49 PM UTC-6, Ben Fritz wrote:
            > > On Friday, February 22, 2013 12:18:50 PM UTC-6, hackware wrote:
            > > > I wish to issue a colon command to move a "seeded" search match
            > > > to after current line.
            > > >
            > > > like the following:
            > > >
            > > > :'a,'bg/ZZZ/m.+1
            > > >
            > > > 'a and 'b are set and around search area containing the "ZZZ"
            > > > seeded line to be moved...
            > >
            > > So . in a :g command refers to each line acted on.
            >
            > did not realize that :g set current line...
            >
            > guess i'll have to figger out yank/put from registers...
            > (working up to writing a script...)

            As Ben suggests, you can do something like

            :kq|'a,'bg/ZZZ/m'q+1

            where "kq" drops the "q" mark on the current/initial line, allowing
            it to then be referenced as the target for the move.

            -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.
          Your message has been successfully submitted and would be delivered to recipients shortly.