copy paste vim 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: paste vim

p 
(use v to highlight, y to copy, p to paste)

Example 3: 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.

Example 4: copy from vim to clipboard

Use "+ to copy to the system clipboard 
i.e. "+y instead of y

Likewise you can paste from "+ to get text from the system clipboard
i.e. "+p instead of p