Neovim: yank, delete and pasting cheatsheet

Short cheatsheet for moving lines around in neovim

A cheatsheet for common yank (copy), delete (cut), and paste commands in Neovim. Yanking is used to copy text without removing it, with commands like yy to copy a line or y$ to copy from the cursor to the end of a line. Deleting, which acts as a “cut” operation, removes text and stores it for pasting, with common commands like dd to cut a line or dG to cut from the current line to the end of the file. Pasting, done with p or P, allows you to insert the copied or cut text either after or before the cursor. Neovim also supports visual selection for targeted operations and includes register management to handle multiple copies or cuts simultaneously. For those needing clipboard integration, commands like "+y and "+p enable seamless interaction with the system clipboard, making these commands flexible for a variety of workflows.


Yanking (Copy)

Command Description
yy Yank (copy) the current line.
3yy Yank 3 lines starting from the current line.
y$ Yank from the cursor to the end of the line.
y^ Yank from the cursor to the beginning of the line (excluding indentation).
y0 Yank from the cursor to the beginning of the line.
yG Yank from the current line to the end of the file.
ygg Yank from the current line to the beginning of the file.
yw Yank a word starting at the cursor.
yiw Yank the current word under the cursor.
yap Yank the entire paragraph (including surrounding blank lines).
test

Deleting (Cut)

Command Description
dd Delete (cut) the current line.
3dd Delete (cut) 3 lines starting from the current line.
d$ Delete from the cursor to the end of the line.
d^ Delete from the cursor to the beginning of the line (excluding indentation).
d0 Delete from the cursor to the beginning of the line.
dG Delete from the current line to the end of the file.
dgg Delete from the current line to the beginning of the file.
dw Delete a word starting at the cursor.
diw Delete the current word under the cursor.
dap Delete the entire paragraph.

Pasting

Command Description
p Paste below or after the cursor.
P Paste above or before the cursor.

Registers

Command Description
"ay Yank into register a.
"aP Paste from register a.
"0p Paste from the default yank register.
:reg View all registers.

System Clipboard Integration

If clipboard integration is enabled in Neovim (check with :echo has("clipboard")):

Command Description
"+y Yank to the system clipboard.
"+yy Yank the current line to the system clipboard.
"+p Paste from the system clipboard.
"*y Yank to the primary clipboard (Linux).
"*p Paste from the primary clipboard (Linux).

Visual Mode

Command Description
v Enter visual mode.
V Enter visual line mode.
<Ctrl-v> Enter visual block mode.
y Yank selected text.
d Delete (cut) selected text.
"+y Yank selected text to system clipboard.
"+d Cut selected text to system clipboard.