Consider the following text:

<text>

a
b

a
c

a
b
</text>

Place the cursor on the first (empty) line. Execute search:

/b/;?a

The cursor is now on the first 'a' character (in the 2nd line).

Now execute the same search again, using search command history (do
NOT use 'n'). The cursor goes to the final 'a' character, on the next-
to-last line.

Now place the cursor at the first line. Repeat the search again and it
goes to the first 'a' character. Move the cursor down and press 'n'.
The cursor goes to the second 'a' in the document.

Look at the '/' register. It contains just 'a'.

Here's the relevant :help

>                                                       *//;* *E386*
> A very special offset is ';' followed by another search command.  For 
> example: >
>
>    /test 1/;/test
>    /test.*/+1;?ing?
>
> The first one first finds the next occurrence of "test 1", and then the first
> occurrence of "test" after that.
>
> This is like executing two search commands after each other, except that:
> - It can be used as a single motion command after an operator.
> - The direction for a following "n" or "N" command comes from the first
>   search command.
> - When an error occurs the cursor is not moved at all.
>
>                                                       *last-pattern*
> The last used pattern and offset are remembered.  They can be used to repeat
> the search, possibly in another direction or with another count.  Note that
> two patterns are remembered: One for 'normal' search commands and one for the
> substitute command ":s".  Each time an empty pattern is given, the previously
> used pattern is used.
>

I note that "this is like executing two search commands after each
other", so I think what is happening is Vim really does execute two
search commands after each other, including setting the "/ register.
But //; is considered an offset, and :help last-pattern says that the
last offset is remembered along with the search pattern.

To me, this looks like a bug, but maybe I'm missing something? I
cannot think of any good reason for the search pattern register to get
the pattern from the search offset and discard the search itself,
especially since the direction for n/N is taken from the search itself.

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

Raspunde prin e-mail lui