VIM, búsqueda incremental: ¿Cómo puedo saltar al siguiente resultado y resaltarlo?

When using VIM's incremental search option I usually search and after I got to the first result (it will be highlighted) I use the / key to jump to the next result.


  1. For this I need to 'cancel' my search and go back to Modo normal in order to jump the next result.
  2. Prensado / makes VIM jump to the next result but it won't highlight it.

I am wondering if there is a more efficient way to jump between the results using incremental search and get them highlighted.

preguntado el 08 de noviembre de 11 a las 10:11

3 Respuestas

The customary key for jumping to the next search result is 'n'.

I'm not entirely sure what you mean about highlighting - all search results should be highlighted if hlsearch is set, and for me it makes no difference if I go to the next result with 'n' or with '/'.

respondido 08 nov., 11:14

Matthew, thanks. However, I do incremental search, type (it jumps and highlights) than I press ENTER than use 'n' and the cursor jumps to the next result. But it is not highlighted. Do you think it should act differently? - zoltanctoth

Mine just highlights all of them straight away - if there are multiple search results visible in the buffer at the same time, I can see they've all got yellow backgrounds. This is the default configuration on my system, and IIRC is controlled by the 'hlsearch' setting. - Matthew Walton

And 'N' to search backwards. - sunsations

@MatthewWalton any idea, how i can jump a fixed number of results in search. I mean for example jump to the 10th matching line - GP cyborg

@GPcyborg Try [number]n? That should perform n [number] times, i.e. go forward n resultados. - Nic

If you want to highlight all search hits you should set hlsearch no incsearch.

respondido 08 nov., 11:14

Ese era el problema. Gracias. - zoltanctoth

@zoltanctoth: you should really accept the other answer instead, because he was first and told the same actually. - Benoit

You are right. I have missed the hlsearch part in @matthew's answer. Thanks for noticing. - zoltanctoth

Con Ctrl-t y Ctrl-g you can move between matches without leaving the search mode

respondido 21 mar '21, 21:03

This is what I was looking for. I wanted to have the currently selected match to be highlighted. - Timothy Pulliam

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.