Monday, July 19, 2010

Re: Default search changed by search and replace

On 2010-07-19, Mark Butler wrote:
> The behavior of the 'n' command appears to have recently changed. It
> used to always repeat the last _search_. Now it appears to repeat the
> search implied by the last _search and replace_, when there has been
> an intervening search and replace since the last search.
>
> This is extremely annoying. It is common to search for lines where you
> need to do a search and replace and where what you are searching for
> and what you are replacing is different.
>
> I am not familiar with any vi derivative that has previously behaved
> this way. Is there an option to make vim behave the way it used to?
> Or would perhaps a patch to restore the old behavior be considered?

Just to be clear what you mean, I constructed the following example.

cat
dog
moose
cow
cat
dog
moose
cow

Executing

/cat

and typing 'n' will cause the cursor to jump between the two
instances of "cat". Moving the cursor to the first "moose" line and
executing

:s/moose/deer/

will replace "moose" with "deer" on that line. Now typing 'n' will
cause the cursor to jump to the next "moose" line. This is how it
is supposed to work, and to my knowledge, how it has always worked.
For example, that is how Vim 6.3.82 works. I repeated the
experiment using HP's /usr/bin/vi that ships with HP-UX 11.11 with
the same results.

Can you find an example of a Vim or vi that behaves differently?

Regards,
Gary

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

No comments: