Vim Cheat Scheet
Normal Mode
Follows this structure (number) Operator + (number) motion
Navigating with motions
Moving cursor:
k
: Uph
: Downl
: Rightj
: Left0
: Begin of the line$
: End of the lineb
: Previous wordw
: Next worde
: Next end of word%
: Matching()
,{}
or[]
gg
: Begin of the fileG
: end of the filectrl + o
: Goes back to where you camectrl + i
: Goes forward from where you came-
Multi visual line
gj
: Downgk
: Upg0
: Begin of the lineg$
: End of the line
Text Manipulation
Deletion Operator
-
x
: Char on cursorxp
: Transpose character (delete + paste)
-
d
: Delete motiondd
: Deletes the whole lineddp
: Transpose line (delete line + paste below)dap
: Delete Text Object Paragraphdaw
: Delete Text Object Word- Combined with common Motions:
dw
: Next word of the cursord$
: Deletes cursor to the end of lined0
: Deletes cursor to the begin of the line
Undo/Redo
u
: undo last commandU
: undo all changes in liner
: redo last command
Copy/Paste
-
y
: Copy (Yank)yw
: Copy word (stores in the unnamed registry)yy
: Copy line"ayw
: Copy word to the registry named a
p
: Paste after cursorP
: Paste before cursor
Common Registries:
"_
: Black Hole. Use when you don't want to store information in the unnamed registry."%
Name of the current file"#
Name of the alternate file".
Last inserted text
Use command :reg
to see the values in each register.
Search
/
: Followed by the word you want to search?
: Searches backwards. Followed by the word you want to searchn
: Next item in searchN
: Previous item in search*
Searches for the word in the cursor
It can be used with other operators:
d/renan
: Deletes from the cursor up to the word renanc/renan
: Changes from the cursor up to the word renan
Search character in line
f
: Followed by the character you want to search. Cursor on the char.t
: Followed by the character you want to search. Cursor before the char.F
Followed by the character you want to search. Backwards. Cursor on the char.T
: Followed by the character you want to search. Backwards. Cursor before the char.;
goes to the next occurrence,
goes back to the previous occurrence
It can be used with other operators.
Changing modes
To Insert Mode
From normal to insert mode:
i
: Cursor in the current positiona
: After the Cursor current positionA
: Cursor in the end of the lineo
: Opens a new line. Cursor in the line belowO
: Opens a new line. Cursor in the line above
To Replace Mode
R
: Moves to replace mode
To Visual Mode
v
: Moves to visual mode
Insert Mode
Command Mode
:w FILENAME
saves to disk
:r FILENAME
retrieves files from disk and paste
:r !command
executes command and paste output
:jumps
to see the jumps history in the file and other files
- as a hack you can use
u + ctrl - r
to jump to latest change in the file:changes
use changes to see the list of modifications in the current file in the current file g.
org;
to move the cursor to the changelist history:marks
to see the marks created
substitute command
:s/old/new
or :s/old/new/g
to replace one match or all matches inline
:%s/old/new/g
replaces all matches in the file
:%s/old/new/gc
replaces all matches asking individually