October 2012
346 pages
7h 40m
English
| Tip 86 | 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. Observe:
| 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 ...
Read now
Unlock full access