FG

How can I switch from forward to backward search in Vim?

Fresh3 days ago
Mar 15, 202656029 views
Confidence Score1%
1%

Problem

In Vim, I know that will search forward from the cursor, with and repeating the search forward and backward, respectively. I also know that will search backward from the cursor, with and 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?

Error Output

/

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: How can I switch from forward to backward search in Vim?

Low Risk

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.

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment