FG
💻 Software

Vim - select text highlighted by search?

Fresh6 days ago
Mar 15, 202617531 views
Confidence Score1%
1%

Problem

In vim, I often perform searches to hop to a word or phrase instead of navigating there with . Then I hit to hop between occurrences. Say I've got this text: I type and hit enter. That phrase is highlighted, and I jump to it with . Now I want to visually select that text, maybe to change it or delete it. (Yes, I'm aware of the substitution command.) Since my cursor is at the letter "a" at the beginning of "an arrow," I can hit , then press a couple of times to highlight the entire phrase. But I have a feeling there's a shorter and more semantic way. After all, I've already specified the text I'm interested in. How might I compose a command to say "visually select the current search selection?"

Error Output

Time flies like an arrow; fruit flies like a banana. - Groucho Marx

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: Vim - select text highlighted by search?

Low Risk

You can use in version 7.4 onwards (and to go backwards). It replaces the trick. Search forward for the last used search pattern, like with `n`, and start Visual mode to select the match. See or this Vimcast for more information.

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment