Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim command: how to select a word under cursor in normal mode

Tags:

vim

macvim

xvim

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?

like image 262
Keita Avatar asked Jan 30 '16 22:01

Keita


People also ask

How do I select an entire text in Vim?

To select all in Vim, use ggVG. it allows you to select all in vim of a file's content. To go to normal mode, hit the ESC key first. Then, using the gg keys, we'll jump to the beginning of the file.

How do I jump a word in Vim?

Vim Word Navigation b – go to the previous (before) word. B – go to the previous (before) WORD. w – go to the next word. W – go to the next WORD.

What does do in normal mode Vim?

Normal mode is where one should spend most of their time while using Vim. Remember, this is what makes Vim different. In normal mode, there are multiple ways to move around an open file. In addition to using the cursor keys to move around, you can use h (left), j (down), k (up), and l (right) to move as well.


2 Answers

You can use * and/or # to search for the word under the cursor or viw to visually select the word under the cursor.

like image 163
pfnuesel Avatar answered Sep 29 '22 18:09

pfnuesel


viw does a visual select inside the word. Similarly yiw copies (yanks) the word.

like image 30
Matthew Strawbridge Avatar answered Sep 29 '22 18:09

Matthew Strawbridge