vim操作技巧

Operation skills of VIM:

一.Command Line MOde
1.move the cursor
a | insert character after the cursor
A | insert character at the end of the line
i | insert character before the cursor
I | insert character at the top of the line
o | start a new line beneath the cursor
O | start a new line above the cursor
h | move left     
j | move down     
k | move up   
l | move right
w | move the cursor forward by jumping a word
w | move the cursor forward by jumping a word
b | move the cursor backward by jumping a word
e | move the cursor forward by jumping a word and move to the end of the word
^ | move the cursor to the top of the line
H | move to the first line of current window
M | move to the middle line of current window
L | move to the last line of current window
n | jump to the next sring that mathces
N | jump to the previous sring that mathces
ge | move the cursor backward by jumping a word and move the beginning of the word
gg | move to the first line of current file
n$ | move the cursor to the end of line n
nG | move to line n of current file
zt | move the cursor line to the top of the screen
zz | move the cursor line to the middle of the screen
zb | move the cursor line to the bottom of the screen
'' | jump between previous location and current location
ctrl + D | move the window down half a screen
ctrl + U | move the window up half a screen
ctrl + O | jump to an older position
ctrl + I | jump to an newer position

2.delete character
C | delete all characters which from current location to the end of the line and switch to Insert Mode
D | delete all characters which from current location to the end of the line
nx | delete n characters to the right of the cursor
nX | delete n characters to the left of the cursor
cc | delete current line but keep the indentation
dd | delete current line
db | delete previous  word include space
dw | delete a word include space
daw | delete a word as long as the cursor is in the word include space 
diw | delete a word as long as the cursor is in the word exclude space 
ce | delete a word exclude space and switch to Insert MOde
de | delete a word exclude space
d^ | delete characters from current location to the beginning of the line
d$ | delete characters from current location to the end of the line
dgg | delete characters to the start of the file
dG | delete characters to the end of the file
ns | delete n characters to the right of the cursor
nS | delete n line but keep the indentation

3.copy and paste
Y | copy full line
p | paste copied character after cursor
P | paste copied character before cursor
yw | copy a word include space
ye | copy a word exclude space
y^ | copy character from current location to the beginning of the line
y$ | copy character from current location to the end of the line
yy | copy full line

4.undo,redo
u | undo the previous edit operation
U | undo all edit operations about the line
ctrl + R | redo the undone operation

5.find string
* | select the word where the cursor is
# | select the word where the cursor is
fx | move to the first character 'x'
gd | select the word where the cursor is
/str | find string "str"
/^str$ | find line only include string "str"
?str | reverse lookup strings "str"

6.replace character
r | replace a character
R | replace more than one character

7.mark
ma | set a mark a to current location
`a | jump to a location marked a

other
v | start visual mode for partial selected characters
V | start visual mode for full line operation
. | repeat previous operation
ZZ | save the file and exit
ctrl + G | display the position of the cursor in the file
ctrl + v | start visual mode for rectangular block operation

二.Bottom Line Mode
:q! | abandon modificaion and exit
:wq | save modificaion and exit
:wqa | save modificaion and exit all window
:help | Open a window and display the help file in read-only mode
:jumps | show a list of locations to jump to
:marks | show all marks
:set number | add a line number to the front of each line
:set nonumber | no line number is displayed
:set ignorecase | ignore the case of the letter
:set noignorecase | do not ignore the case of the letter
:set hlsearch | highlight all matched strings
:set nohlsearch | do not highlight all matched strings

阅读更多
换一批

没有更多推荐了,返回首页