vim notes

vim 真是太好用了

The basic

In view mode:

CommandUsage
:w
:q
:wq
:wq!
Save
quit
Save and quit
confirm save and quit
:number
eg: :129
Go to line number
Go to line 129
20|
25h
25l
Go to column 20
Move cursor 25 characters ahead
move cursor 25 character after
/keyword
?keyword
n
N
Search keyword from beginning of file
Search keyword from the end of file
Go to next find result
Go to previous find result
$
9
:1
G
Go to beginning of current line
Go to the end of current line
Go to line 1
Go to the end of file
ctrl + d
ctrl + u
Move half of the view downwards
Move half of the view upwards
i
a
r
Insert: start editing at the current cursor position
Append: start editing after the current cursor position
Replace: replace the character at the current cursor position
u
Ctrl + r
Undo
Redo
h
j
k
l
Move the cursor to left
Move the cursor to down
Move the cursor to up
Move the cursor to right
e
E

w
W
Go to the end of a word separated by special character
Go to the end of a word separated by space

Go to the start of a word separated by special character
Go to the start of a word separated by space

Display and not display line number:

:set number
:set nonumber

marco

// record a marco and named it "a"
// in view mode, enter "q" then the name of the marco, a-z

ie: qa

// then vim will enter recording mode. You may see "recording @a" in bottom left corner

// To play the marco once
// in view mode enter "@" followed by the name of the marco, in my case, a

ie: @a

// To play the marco several times
// in view mode, enter the number of times followed by "@" and the name of the marco

ie: 10@a

Posted in notesTagged ,