Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
add comment

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.

share|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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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