Vim incremental search

Michael Sanchez picture Michael Sanchez · Sep 3, 2014 · Viewed 17.8k times · Source

I'm using putty on a Linux machine. My usual method for searching in vi is entering the slash /, then my search string, enter, then go through all the matches by n or shift + n.

I was wondering if vi had a feature like Eclipse's Incremental Search (ctrl + j), wherein as I type, it jumps to the next logical match. I think one of my office mates used to do it but I'm not sure.

Answer

paxdiablo picture paxdiablo · Sep 3, 2014

If you're using vim (and who isn't nowadays), you can enable incremental search with:

:set incsearch

Then just use the regular search command / and it will move the highlight as you add characters to the search string.

I also like hlsearch as well since it highlights all found items (once the search command is done) for easy viewing.