vim copy word code example

Example 1: how to copy in vim

Place the cursor on the line you want to begin cutting.
Press V to select the entire line, or v to select from where your cursor is.
Move the cursor to the end of what you want to cut, using h,j,k, or l
Press y to copy it, or d to cut it.
Place the cursor where you would like to paste your copied stuff.
Press P to paste it before your cursor, or p to paste it after the cursor.
You can copy and paste between buffers.

Example 2: vim copy line

yy - Yank (copy) the current line, including the newline character.
3yy - Yank (copy) three lines, starting from the line where the cursor is positioned.
y$ - Yank (copy) everything from the cursor to the end of the line.
y^ - Yank (copy) everything from the cursor to the start of the line.
yw - Yank (copy) to the start of the next word.
yiw – Yank (copy) the current word.
y% - Yank (copy) to the matching character. By default supported pairs are (), {}, and []. Useful to copy text between matching brackets.

Tags:

Misc Example