Domanda

for example i have the following text :

My eyes are red , but the red eyes doesn't mean nothing

Red will  always be red .

My best color is red!

i want vim to search and tell or show me all the spots that "red" word exists.

can vim do something like that?

È stato utile?

Soluzione

You can use / to search forward in the file and ? to search backwards in the file.

n goes to the next instance of your search text and N goes to the previous instance.

:set hlsearch turns on highlighted searching.

Example:

/red

Altri suggerimenti

What about the standard search ?

:set ignorecase
:set hlsearch
:set incsearch
/red

Type the following, verbatim into vim

 :set hlsearch <enter>
 /red <enter>

in Vim:

In command mode: make sure you have set the highliting if you want your word to be highlited when searched: :set hlsearch.

Then go on top of the word you want, and press : * (in command mode) (multiple times, it will go from one to the next, and wrap around to the beginning. Nifty!)

You can use /red\c to search forward and ignore case, or ?red\c to search backward.

Or, move your cursor to "red", press Ctrl+* to go to the next instance. Ctrl+# goes to the previous instance.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top