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

search with offset

Expand Messages
  • Marcin Szamotulski
    Dear Vim Use, Do you know how to repeat vim search preserving the offset. For example /hello/;?Mark? the n and N commands seems to forget about the offset,
    Message 1 of 5 , Jun 1, 2013
    • 0 Attachment
      Dear Vim Use,

      Do you know how to repeat vim search preserving the offset. For example
      /hello/;?Mark?
      the n and N commands seems to forget about the offset, well actually
      they forget about the patter and remember only the offset. I would like
      to repeat the whole search with offset though. The question is if you
      know a plugin that does it, if not I can implement it myself. I have
      found that vim remembers the whole search pattern+offset in the search
      history (:h :histget()).

      Best regards,
      Marcin

      --
      --
      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.
    • Shlomi Fish
      Hi Marcin, On Sat, 1 Jun 2013 11:40:19 +0000 ... You can: 1. Set up a mark using ma or whatever. 2. Record a register repeat of: qs`a/min q Then pressing
      Message 2 of 5 , Jun 1, 2013
      • 0 Attachment
        Hi Marcin,

        On Sat, 1 Jun 2013 11:40:19 +0000
        Marcin Szamotulski <mszamot@...> wrote:

        > Dear Vim Use,
        >
        > Do you know how to repeat vim search preserving the offset. For example
        > /hello/;?Mark?
        > the n and N commands seems to forget about the offset, well actually
        > they forget about the patter and remember only the offset. I would like
        > to repeat the whole search with offset though. The question is if you
        > know a plugin that does it, if not I can implement it myself. I have
        > found that vim remembers the whole search pattern+offset in the search
        > history (:h :histget()).
        >

        You can:

        1. Set up a mark using "ma" or whatever.

        2. Record a register repeat of:

        qs`a/min<CR>q

        Then pressing "@s" will keep searching from this mark onward.

        Regards,

        Shlomi Fish

        --
        -----------------------------------------------------------------
        Shlomi Fish http://www.shlomifish.org/
        List of Portability Libraries - http://shlom.in/port-libs

        SMG: It was 1997-1998ish, Buffy started airing. So one day a group of
        yeshivah pupils arrived to the studios saying they have some numereological
        insights from the Jewish bible, about what will happen in Sunnydale next.
        http://www.shlomifish.org/humour/Summerschool-at-the-NSA/

        Please reply to list if it's a mailing list post - http://shlom.in/reply .

        --
        --
        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
        ... This is strange, as n/N remember the other {offset} modifiers: /thing/e n goes to the end of the next thing match. I d consider classifying this as a
        Message 3 of 5 , Jun 1, 2013
        • 0 Attachment
          On 2013-06-01 11:40, Marcin Szamotulski wrote:
          > Do you know how to repeat vim search preserving the offset. For
          > example /hello/;?Mark?
          > the n and N commands seems to forget about the offset, well actually
          > they forget about the patter and remember only the offset.

          This is strange, as n/N remember the other {offset} modifiers:

          /thing/e
          n

          goes to the end of the next "thing" match. I'd consider classifying
          this as a bug: either in behavior, or in (lack of)
          clarification in the documentation.

          > I have found that vim remembers the whole search
          > pattern+offset in the search history (:h :histget()).

          With this information, you could do something like

          :nnoremap n /<up><cr>

          to get "n" behavior, but it gets tricky when you want to reverse it
          (you'd have to swap the "/" for "?" in the "right" placs, and define
          whether you want to search backwards for pattern#1, then forwards
          for pattern#2 (what I suspect you want), or backwards for pattern#1
          and then backwards further for pattern#2.

          -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.
        • Marcin Szamotulski
          ... Thank you both Tim and Shlomi, I tested this with vim -u NONE --noplugin so I will report it on vim_dev. I will try to use your maps. They also have the
          Message 4 of 5 , Jun 1, 2013
          • 0 Attachment
            On 07:46 Sat 01 Jun , Tim Chase wrote:
            > On 2013-06-01 11:40, Marcin Szamotulski wrote:
            > > Do you know how to repeat vim search preserving the offset. For
            > > example /hello/;?Mark?
            > > the n and N commands seems to forget about the offset, well actually
            > > they forget about the patter and remember only the offset.
            >
            > This is strange, as n/N remember the other {offset} modifiers:
            >
            > /thing/e
            > n
            >
            > goes to the end of the next "thing" match. I'd consider classifying
            > this as a bug: either in behavior, or in (lack of)
            > clarification in the documentation.
            >
            > > I have found that vim remembers the whole search
            > > pattern+offset in the search history (:h :histget()).
            >
            > With this information, you could do something like
            >
            > :nnoremap n /<up><cr>
            >
            > to get "n" behavior, but it gets tricky when you want to reverse it
            > (you'd have to swap the "/" for "?" in the "right" placs, and define
            > whether you want to search backwards for pattern#1, then forwards
            > for pattern#2 (what I suspect you want), or backwards for pattern#1
            > and then backwards further for pattern#2.
            >
            > -tim
            >

            Thank you both Tim and Shlomi,

            I tested this with vim -u NONE --noplugin so I will report it on
            vim_dev. I will try to use your maps. They also have the additional
            feature that they do not change the direction of searches. Let me see
            if I can forget the vim defaults :D

            Best regards,
            Marcin

            --
            --
            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.
          • Yann Thomas-Gérard
            ... IMHO, it needs documentation clarification. See :h last-pattern The last used pattern and offset are remembered. This excludes the very special offset
            Message 5 of 5 , Jun 3, 2013
            • 0 Attachment
              > This is strange, as n/N remember the other {offset} modifiers:
              >
              >
              >
              > /thing/e
              >
              > n
              >
              >
              >
              > goes to the end of the next "thing" match. I'd consider classifying
              >
              > this as a bug: either in behavior, or in (lack of)
              >
              > clarification in the documentation.

              IMHO, it needs documentation clarification. See :h last-pattern

              "The last used pattern and offset are remembered."

              This excludes the very special offset ";". So in:

              /foo/e;/bar/e

              /bar/e

              only will be remembered.

              --
              --
              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.