1

I looking more for a method that is "built-in" to vi, and not something that I could do in my .vimrc. Though, solutions for .vimrc are appreciated. :-)

When I want to search a string, sometimes that string is already typed in and I want to see if it's being used elsewhere on the document. For example: I see a variable, but I want to know where it was initialized, so I'll search that variable's name and keep clicking n or SHIFT+n til I find it.

int c = 0;
.
. //100s or 1000s of lines of code
.
c = 5;

Is there a shortcut way to search the string that my cursor is hovered over? Not the mouse cursor, but the vi cursor (if that makes sense).

1 Answer 1

5

In vim just press * to search forward ... # will search backwards.

Oh: prepend * and # with g to also match partial words.

1
  • You've got it all mixed up. * for forward, # for backward, g*/g# for not whole words. n/N to repeat search in the same/reverse direction. Apr 19, 2013 at 22:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .