October 2015
Intermediate to advanced
356 pages
7h 54m
English
| Tip 87 | Search for the Current Visual Selection |
In Normal mode, the * command lets us search for the word under the cursor. Using a small amount of Vim script, we can redefine the * command in Visual mode so that, instead of searching for the current word, it searches for the current selection.
In Visual mode, the * command searches for the word under the cursor:
| Keystrokes | Buffer Contents | ||
|---|---|---|---|
{start} |
| ||
* |
|
We start off in Visual mode with the first three words selected and our cursor placed on the word “sea.” When we invoke the * command, it searches forward for the next occurrence of the word “sea,” extending the range of the ...