Вопрос

I have incsearch and hlsearch enabled

So I hit / to enter search mode.

Then I type text I want to search for and it finds the first occurrence of the text I typed.

Then I want to jump to next occurrence of the text I typed without exiting search mode so that I could refine my search text later without having to exit to normal mode, then hitting n and then going back to search mode by hitting / again.

If this is possible, how can I do it?

Это было полезно?

Решение

The best thing that I can find that you can do is the following:

Search for your pattern using /blah

Then, hit n or ? until you see what's out there...

Then go back to / and press CTRL-r /

this will bring back the last pattern that you searched for, so you can continue entering more text there...

I'm sure you can remap that combination to some key so that you can quickly go back to the search with the pattern already entered.

Другие советы

I've found a way thanks to bwana147 from #vim irc channel on freenode.net

:cnoremap <c-n> <CR>n/<c-p>

After that typing text in search mode and then hitting ctrl-n goes to next occurrence of that text without exiting search mode

I have incsearch and hlsearch enabled. So I hit / to enter search mode. Then I type text which I want to search for and it finds the first occurrence.

Okey so far ...

Here, I can't quite understand what you're asking.

Then I want to jump to next occurrence of the text I typed without exiting search mode

This is done by pressing n

so that I could refine my search text later without having to exit to normal mode, then hitting n and then going back to search mode by hitting / again.

You got me lost here ... isn't this behaviour exactly what incsearch enables you?

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top