Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
copy word under cursor in Vim
copy/delete word under cursor in Vim
yw / byw
Assuming that the cursor is at the first character of the word simply do this in command mode:
yw
y is for yank and w is for word.
Other ways of doing the same thing which are not as efficient:
vey
the v starts visual select mode. e tells vim to move to end of word. y yanks or copies the word. to delete replace y with x.
if the cursor is somewhere in the middle of the word, add a b before the command as in:
byw
or
bvey
# http://www.littletechtips.com/2011/05/how-to-copydelete-word-under-cursor-in.html
@tyler-hitzeman

This comment has been minimized.

Copy link

tyler-hitzeman commented Mar 27, 2019

Thank you. You can also yaw to yank the entire word regardless of where the cursor is located.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.