Vim is a powerful text editor,it ships with every unix-like operating system. It is a editor to which if you get addicted you can’t go back. Here’s a cheat sheet I prepared for you guys.
Note! -
<x>
- Means imaginary number
<c>
- Means - imaginary character
Modes in VIM -
Normal Mode
- To run commands and move through h,j,k,l keys in the document
Insert Mode
- To type on the document
Visual Mode
- To select text inside the document
Commands in Vim:
:q
- Quits
:wq
- Saves & quits
:q!
- Quits without saving
i or a
- Insert Mode
Shift + i
- Insert mode with ignoring white spaces
v
- For Visual Mode
GG
- Go to first character of document
Shift+G
- Go to last character of document
O
- Go to first character of the line
<x>G
- Go to Line number
<x>l
- Go characters up
<x>k
- Go characters right
<x>h
- Go characters left
<x>j
- Go characters down
x
- Deletes a character
<x>x
- deletes characters
<x>d
- Delete Line
u
- Undo
<x>u
- Undo times
Ctrl + r
- Redo
dw
- Delete a whole word
dd
- Deletes a whole line
d$
- Deletes whole line from cursor to the end
w
- Go to beginning character of word
W
- Moves to word & ignores special characters
b
- Moves to preceding word
B
- Moves to preceding word & ignores special characters
e
- Moves to last character of word
E
- Moves to last character of word & ignores special characters
A
- Takes to last character of line & appends
<x>
- Takes to character of line
<x>w
- Go to beginning character of word
<x>+shift+g+p
- Moves a line to number
r
- replace a character
C
- Deletes whole line from cursor to the end & takes in insert mode
cw
- Deletes a word and takes in the insert mode
c$
- Deletes the whole line from the cursor to end & takes in insert mode
jk
- Moves by logical line
gj
- Moves by visual line
f<c>
- Moves forward to character
F<c>
- Moves backward to character
t<c>
- Moves forward to preceding / until character to character
T<c>
- Moves backward to preceding character to character
s
- deletes a character
S
- deletes entire line
O
- takes us to next line & insert
yw
- Copy’s the next word
yy
- Copy’s the whole line
y$
- Copy’s whole line from cursor to the end
p
- to paste
%
- To highlight open & close parentheses
/<c>
- To search instance forward in the document
?<c>
- To search instance backwards in the document
N
- Takes us to the next instance of the search
Ctrl + O
- Takes us back to the instance that you were before
Ctrl + i
- Takes us next to the instance that we’re before
:%/s/<c>/<c2>/g
- Replace with in the document
<x>,<.x...>s/<c>/<c2>/g
- Replace with in the lines
<x>,<.x...>s/<c>/<c2>/gc
- Replace with in the lines & ask every time
:!<command>
- Runs in terminal in vim
:term
- Launch terminal inside vim
That's it for today, soon to be bringing a post on vim customization.
Top comments (0)