linux
web
life
ctrv
man
link

Vim Cheat Sheet

Vim Cheat Sheet

Here is my personal cheat sheet for commands in the Vim editor that I frequently use or tend to forget.

Navigation & Cursor Movement:
h, j, k, l — Left, down, up, right
w — Jump forward to the start of a word
b — Jump backward to the start of a word
0 — Move to the start of the line
$ — Move to the end of the line
gg — Go to the first line of the document
G — Go to the last line of the document

Editing:
i — Enter Insert mode before cursor
a — Enter Insert mode after cursor
o — Open a new line below current line
u — Undo last action
Ctrl + r — Redo
yy — Copy current line
p — Paste after cursor
dd — Delete (cut) current line

Search & Replace:
/pattern — Search forward for pattern
?pattern — Search backward for pattern
n — Next match
N — Previous match
:%s/old/new/g — Replace all occurrences of ‘old’ with ‘new’

Saving & Exiting:
:w — Save file
:q — Quit
:wq — Save and quit
:q! — Quit without saving

That’s all for now. I will update this cheat sheet from time to time.