John Dibling
John Dibling

Reputation: 101456

Highlight search pattern without moving cursor

In vim, is it possible to highlight a search pattern without moving the cursor?

For example, if I want to find m_depthTable I could do:

/m_depthTable

and that will highlight all instances of m_depthTable, but it will also move to the next occurance.

I want to highlight without moving. Possible?

Upvotes: 6

Views: 394

Answers (3)

FDinoff
FDinoff

Reputation: 31429

You could do a substitute command with the n flag. This won't move the cursor or do the substitute.

:s/pattern//n

Upvotes: 7

Kent
Kent

Reputation: 195059

just

/pattern<enter>

then press ``

Upvotes: 7

rpeshkov
rpeshkov

Reputation: 5047

You can write directly into register that contains last search pattern:

:let @/="m_depthTable"

Upvotes: 2

Related Questions