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?
-
@pfnuesel `*` selects the next occurrence of the word under the cursor, because it's a search command, not a select command. – Dan Lowe Jan 30 '16 at 23:02
-
1@DanLowe Yep, you're right, i deleted my comment. But `viw` should do the job. – pfnuesel Jan 30 '16 at 23:03
-
Won't that put you in visual mode? Is it even possible to select stuff in normal mode? – MinusFour Jan 30 '16 at 23:06
-
1Thanks @pfnuesel and @Matthew-strawbridge for answering my question. The command `viw` is what I was looking for :) – Keita Feb 01 '16 at 18:06
-
I mapped `v` to `viw` in normal mode to select a word with one-key typing. It seems it's working well. – Keita Feb 01 '16 at 18:08
-
The Vim documentation `:help visual-operators` explains how to select a word `vaw` and an inner word `viw`, as well as paragraphs and various variations of parenthesis blocks and quoted strings. – Paul Rougieux Oct 13 '20 at 08:28
-
https://stackoverflow.com/a/66910215/9384511 – ABN Apr 01 '21 at 19:30
5 Answers
You can use *
and/or #
to search for the word under the cursor or viw
to visually select the word under the cursor.

- 14,093
- 14
- 58
- 71
-
5
-
31@minitauros `i` stands for inner or inside here. `viw` visually selects the inner word. It will be immediately clear what's meant if you open a document with parentheses. Then put your cursor anywhere inside the parentheses and type `vi(`. It will select everything inside the parentheses. This also works with quotation marks, e.g. `vi"` or `vi'`. If you want to select the parentheses (or quotation marks) as well, you can use `va(` (or `va"`). But I do not know, what the `a` here stands for. And, of course, you cannot just visually select, but also e.g. delete (`di(`) or yank (`yi(`). – pfnuesel Jan 02 '19 at 14:57
-
6
-
1@pfnuesel If your cursor is in the middle of the word, `vw` selects from the middle to the end of the word, while `viw` selects the whole word even if your cursor is in the middle of the word. – stackzebra Feb 11 '20 at 11:49
-
7And `ciw` to clear the word under the cursor and swap into insert mode so you can start typing something to replace it. – MattCochrane Jun 08 '20 at 10:25
-
`v + i + {` or `v + i + }` Select content inside `{ }`, `{ }` are not selected. `v + a + {` or `v + a + }` Select content around `{ }`, `{ }` are also selected. – PR7 Apr 02 '22 at 04:55
viw
does a visual select inside the word. Similarly yiw
copies (yanks) the word.

- 19,940
- 10
- 72
- 93
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.

- 2,785
- 22
- 27
-
15`vaw` isn't exactly the same. It also selects leading or trailing whitespace. – studgeek Oct 04 '18 at 00:07
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.

- 95
- 1
- 5
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).

- 6,769
- 9
- 52
- 115