vim cut line code example

Example 1: vim delete line

# Basic syntax:
dd

# Note, add a number in from of dd to delete that many lines, e.g.:
5dd # Delete the next 5 lines

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.

Tags:

Misc Example