Reputation: 1687
I'm looking for a Vim command to select a word under cursor in normal mode, like double-clicking by mouse. Does it exist like this?
Upvotes: 104
Views: 88034
Reputation: 6981
After using *
, if you want to use the text in a command you can do the <C-r> <C-w>
trick too (after pressing :
or your equivalent).
Upvotes: 1
Reputation: 125
To select a word under a cursor I use the combination of bve
Be aware though that if the cursor points to a first character you just need ve
combination.
Upvotes: 9
Reputation: 2891
Personally, I am prefering vaw
, yaw
instead of viw
or yiw
as a
indicates around.
On the similar lines. I use
vat
to select tag.
va(
or va{
v%
to select matching closing tag. In some other places ev%
It is making more sense to me as the intention is to select the complete word not inside.
At the end, it all comes down to our personal preference.
Upvotes: 35
Reputation: 20620
viw
does a visual select inside the word. Similarly yiw
copies (yanks) the word.
Upvotes: 71
Reputation: 15320
You can use *
and/or #
to search for the word under the cursor or viw
to visually select the word under the cursor.
Upvotes: 168