Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 25 down vote accepted

Simply typing a ? without any text following it will re-run the search backwards.

I.e. 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

You must log in to answer this question.

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