53
10
In vim, I often perform searches to hop to a word or phrase instead of navigating there with h/j/k/l
. Then I hit n
to hop between occurrences.
Say I've got this text:
Time flies like an arrow; fruit flies like a banana. - Groucho Marx
I type /an arrow
and hit enter. That phrase is highlighted, and I jump to it with n
.
Now I want to visually select that text, maybe to change it or delete it. (Yes, I'm aware of the :s
substitution command.)
Since my cursor is at the letter "a" at the beginning of "an arrow," I can hit v
, then press e
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?"
This duplicates a comment to another answer and is not very useful as it stands. It might be a good idea if you quoted the documentation so that your answer can stand on its own. – bwDraco – 2015-01-22T00:13:23.380
2Happy to make the answer better but I'm not sure whether that would help. The question lays out the objective neatly ("visually select the next search result") and
gn
does exactly as asked. Submitting it as a separate answer emphasises that it's a complete substitute forv//e
. I just edited my answer to add documentation, is that better? – David Lord – 2015-01-22T00:23:20.737That's good, thanks. If you need help, be sure to check out the [tour] and [help]. Welcome to Super User, and we hope you enjoy your stay. – bwDraco – 2015-01-22T00:31:27.927
1Fantastic! Thanks for updating this thread with the latest and greatest. :) – Nathan Long – 2015-01-22T17:01:38.410