I am trying to find an easy way to copy the word that the caret is currently on top of. I know that I can select to the front of the word: press v e y. But this seems crazy, I can simply press * above a word to search for it, surely there is a better way to copy the word. Maybe even in a single key press?
Asked
Active
Viewed 708 times
3
-
3You can map a key to `yiw`. eg. `nmap
w yiw` – satoru Feb 17 '12 at 01:29
1 Answers
13
You can use y i w (Yank In Word). Though it is just as many keystrokes. If you are at the beginning of the word you can drop the i and use either y w or y e.
Alternatively you can map the command to a key any way you like. For example, you could put this in your vimrc file:
nmap <F8> yiw
The F8 key is right near the * key so it would be easy to remember that it acts similar to the * word highlight. This would be a single key to yank the word.
UPDATE:
Satoru.Logic's comment is definitely a good way to go. If you are not sure what <leader>
means, have a look at this post.

Community
- 1
- 1

Jason Down
- 21,731
- 12
- 83
- 117