ssh에서 vim을 이용해 파일을 수정할 일이 많아져서 정리해본다.
크게 insert모드와 normal모드로 visual모드로 나눠진다.
:q
- quit
:w
- write(save)
:wq
- write & quit
:q!
- quit override (not saving anything)
o
- new line below
O
- new line above
b
- previous word
W
- next word (ignore special characters)
zz
- centerd selected line
4
+ j/<Down Arrow>
- move four lines down
A
- move to end of the line and insert
I
- move to start of the line and insert
dw
- delete word
D
- delete rest of line
dd
- delete line - deletes the whole line wherever your cursor is
cc
- change line - change the whole line wherever your cursor is
u
- undo
ctrl + u
- redo
Ctrl + u
- undo
arrow key
- select
d
- delete
y
- yanking(copy)
c
- change
p
- paste
ctrl + v
- visual block
shift + v
- visual line
>
- indent
<
- unindent
/word + enter
- search for "word"
n
- next occurenceN
- previous occurence*:s/old/new/g - replace word only on current line
:%s/old/new/g - replace everywhere