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

buggy interaction of +/searchpat/ startup arg and nowrapscan

Expand Messages
  • Rob Retter
    The vim help describes the +/searchpat/ startup arg as follows: +/{pat} The cursor will be positioned on the first line containing pat in the first file
    Message 1 of 6 , Jun 13, 2014
    • 0 Attachment
      The vim help describes the +/searchpat/ startup arg as follows:

      +/{pat} The cursor will be positioned on the first line containing
      "pat" in the first file being edited (see |pattern| for the
      available search patterns).


      That description is false when one sets nowrapscan in one's vimrc (as I do, because I don't like wrapscan) and one has edited a file before.

      The problem is, having edited a file before, there's an entry in the viminfo file which records the line where you left vim when you last edited the file.

      And now, if your search pattern appears in the file *before* that line you were last editing, either your line positioning is wrong (you're on whatever occurrence of the pattern is *after* your "last" line), or you get the E385 error message about "search hit BOTTOM without match".

      vim's searching beyond that "last line you edited" rather than (as in the arg description) "the first line containing pat in the first file being edited").

      I believe vim should always begin searching at line 1 when a searchpat command line argument is given. Unfortunately, I don't expect that, because I've perceived a strong tendency in Brad to reflexively reject any bug report that doesn't involve vim actually crashing. Whatever else vim does is, by definition, correct. Sigh.

      --
      --
      You received this message from the "vim_dev" 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_dev" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/d/optout.
    • Ben Fritz
      ... I disagree, I think the help is wrong. +/pattern/ is actually saying run the command /pattern/ after launching Vim . This command is just giving a range
      Message 2 of 6 , Jun 13, 2014
      • 0 Attachment
        On Friday, June 13, 2014 6:15:26 PM UTC-5, Rob Retter wrote:
        > The vim help describes the +/searchpat/ startup arg as follows:
        >
        > +/{pat} The cursor will be positioned on the first line containing
        > "pat" in the first file being edited (see |pattern| for the
        > available search patterns).
        >
        >
        > That description is false when one sets nowrapscan in one's vimrc (as I do, because I don't like wrapscan) and one has edited a file before.
        >
        > The problem is, having edited a file before, there's an entry in the viminfo file which records the line where you left vim when you last edited the file.
        >
        > And now, if your search pattern appears in the file *before* that line you were last editing, either your line positioning is wrong (you're on whatever occurrence of the pattern is *after* your "last" line), or you get the E385 error message about "search hit BOTTOM without match".
        >
        > vim's searching beyond that "last line you edited" rather than (as in the arg description) "the first line containing pat in the first file being edited").
        >
        > I believe vim should always begin searching at line 1 when a searchpat command line argument is given. Unfortunately, I don't expect that, because I've perceived a strong tendency in Brad to reflexively reject any bug report that doesn't involve vim actually crashing. Whatever else vim does is, by definition, correct. Sigh.

        I disagree, I think the help is wrong.

        +/pattern/ is actually saying "run the command /pattern/ after launching Vim".

        This command is just giving a range specifier without a following command, which always jumps to the line. Since a search pattern as a range always starts the search at the cursor position, then it should always start from the current cursor position.

        Now, you are having a problem because your cursor doesn't start at the top of the file.

        But, that's because of an autocmd in your .vimrc, to restore cursor position when re-editing a file. Vim's default behavior is to always start at the top of a file.

        If you want it to start at the top of the file, then do:

        vim +1 +/pattern/

        or:

        vim +1,/pattern/

        --
        --
        You received this message from the "vim_dev" 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_dev" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
        For more options, visit https://groups.google.com/d/optout.
      • David Larson
        ... Who s Brad? Do you mean Bram? ... That hasn t been my experience with Bram, assuming that s who you re talking about. He s been very responsive to fix
        Message 3 of 6 , Jun 17, 2014
        • 0 Attachment
          On Friday, June 13, 2014 4:15:26 PM UTC-7, Rob Retter wrote:
          > Unfortunately, I don't expect that, because I've perceived a strong tendency in Brad...

          Who's Brad? Do you mean Bram?

          > ... to reflexively reject any bug report that doesn't involve vim actually crashing.

          That hasn't been my experience with Bram, assuming that's who you're talking about. He's been very responsive to fix bugs. He's also very careful to not change VIM's expected behavior for the large crowd of current users. His high responsiveness and careful updates are, to a large degree, what makes VIM so well received. I've interacted with Bram off and on over 20 years and all of my interactions with him have been very positive and productive. There have been some "features" that I've suggested that he has rejected, but always for very good reason and I respect his judgement.

          > Whatever else vim does is, by definition, correct.

          I don't know where you get this idea, but it just doesn't ring true.

          --
          --
          You received this message from the "vim_dev" 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_dev" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
          For more options, visit https://groups.google.com/d/optout.
        • Rob Retter
          ... I can see how, given the definitions you describe, the current behavior results. But that result, while technically consistent, is not desirable in the
          Message 4 of 6 , Jun 17, 2014
          • 0 Attachment
            On Friday, June 13, 2014 4:48:48 PM UTC-7, Ben Fritz wrote:
            >
            > I disagree, I think the help is wrong.
            >
            > +/pattern/ is actually saying "run the command /pattern/ after launching Vim".
            >
            > This command is just giving a range specifier without a following command, which always jumps to the line. Since a search pattern as a range always starts the search at the cursor position, then it should always start from the current cursor position.

            I can see how, given the definitions you describe, the current behavior results. But that result, while technically consistent, is not desirable in the context of starting vim with a search pattern. In this context, I believe the concept of "current position" is problematic, rather than useful.

            > If you want it to start at the top of the file, then do:
            >
            > vim +1 +/pattern/
            >
            > or:
            >
            > vim +1,/pattern/

            This is very useful information for me, and I thank you for your help.

            --
            --
            You received this message from the "vim_dev" 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_dev" group.
            To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
            For more options, visit https://groups.google.com/d/optout.
          • Rob Retter
            ... Yes, please forgive my typo. ... It is the distinction between bugs and VIM s expected behavior which, as with many software products, can produce
            Message 5 of 6 , Jun 17, 2014
            • 0 Attachment
              On Tuesday, June 17, 2014 10:20:05 AM UTC-7, David Larson wrote:
              >
              > Who's Brad? Do you mean Bram?

              Yes, please forgive my typo.

              > That hasn't been my experience with Bram. He's been very responsive to fix bugs. He's also very careful to not change VIM's expected behavior for the large crowd of current users.

              It is the distinction between "bugs" and "VIM's expected behavior" which, as with many software products, can produce disagreement among users. I'm pleased that your experience has been so positive and it may be that Bram's commitment to "not change VIM's expected behavior" is less intransigent than it seemed to me when I encountered it.

              --
              --
              You received this message from the "vim_dev" 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_dev" group.
              To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
              For more options, visit https://groups.google.com/d/optout.
            • Ben Fritz
              ... By default, Vim always places the cursor on the first line of a file when opening the file. However, a common addition to a .vimrc, included in
              Message 6 of 6 , Jun 17, 2014
              • 0 Attachment
                On Tuesday, June 17, 2014 12:50:46 PM UTC-5, Rob Retter wrote:
                > On Friday, June 13, 2014 4:48:48 PM UTC-7, Ben Fritz wrote:
                > >
                > > I disagree, I think the help is wrong.
                > >
                > > +/pattern/ is actually saying "run the command /pattern/ after launching Vim".
                > >
                > > This command is just giving a range specifier without a following command, which always jumps to the line. Since a search pattern as a range always starts the search at the cursor position, then it should always start from the current cursor position.
                >
                > I can see how, given the definitions you describe, the current behavior results. But that result, while technically consistent, is not desirable in the context of starting vim with a search pattern. In this context, I believe the concept of "current position" is problematic, rather than useful.
                >

                By default, Vim always places the cursor on the first line of a file when opening the file.

                However, a common addition to a .vimrc, included in vimrc_example.vim distributed with Vim, is to add an autocmd to resume editing from the last position when loading a file. Another suggested autocmd is in :help last-position-jump. If you find Vim starting up somewhere other than the first line of a file, that is NOT the default behavior. You probably have a similar autocmd in your .vimrc somewhere.

                --
                --
                You received this message from the "vim_dev" 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_dev" group.
                To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
                For more options, visit https://groups.google.com/d/optout.
              Your message has been successfully submitted and would be delivered to recipients shortly.