In Vim, I know that / will search forward from the cursor, with n and N repeating the search forward and backward, respectively.

I also know that ? will search backward from the cursor, with n and N repeating the search backward and forward, respectively.

My question is, if I've done a ? search, and I want to re-run that as a / search (so I don't have to keep holding shift to move forward), is there a way to switch the previous search's direction without retyping the search term?

link|improve this question

62% accept rate
feedback

1 Answer

up vote 9 down vote accepted

Simply typing a '?' without any text following it will re-run the search backwards. IE, typing '/' [RETURN] or '?' [RETURN]' will always rerun the last search, but in the direction you want.

link|improve this answer
Wow, that was way easier than I thought. :) Thanks! – Nathan Long Feb 8 '11 at 14:36
Hmmm, and apparently, ? or / followed by the up key cycles through a common history for the two. I thought each had their own history. – Nathan Long Feb 8 '11 at 14:40
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.