Daily used commands of vim
tar -czvf archive.tar.gz my_directory
:q
:q!
:w
:wq
Command | Description |
---|---|
h j k l |
Arrow keys |
Ctrl+f/b |
Forward/backward |
Ctrl+d/u |
Move down/up half page |
G |
Go to the bottom of the page |
gg |
Go to the top of the page |
{ / } |
Forward/Backward one paragraph |
Ctrl+e/y |
Scroll down/up one line |
0 |
Start of line |
^ |
Start of line after white space |
$ |
End of line |
% |
Jump between matching () or {} |
u
: Undo
ctrl+r
: Redo
i
/a
: Start insert mode at/after cursor
I
/A
: Start insert mode at the beginning/end of the line
v
V
ctrl+v
y
: copy the selcted characters in the visual mode
p
: paste after cursor
d
x
:%s/<old>/<new>/g
: replace all with throughout file
:%s/<old>/<new>/gc
: replace all with throughout file with confirmation
/<text>
search for
?<text>
search for backward
- press Esc (to leave editing or other mode)
- hit ctrl+v (visual block mode)
- use the j/k "arrow keys" to select lines you want (it won't highlight everything - it's OK!)
- Shift+i (capital I)
- insert the text you want, e.g.
%
- press EscEsc
No need to go beyond the commands above.