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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui