GVim是一款非常强大的编辑器,在这里介绍一些GVim常用的快捷指令。
vi/vim/gvim + file name
basic
- i : go to insert mode
- esc : go to command
- :w : write into the file (save)
- :q : quit vi
- :q! : force to quit and abort te modification
- :wq : save and quit
move cursor
->/<- : left/right/up/downn
h/j/k/i :left/down/up/right
3h : up 3 times
:w : move forward one word (3w)
:b : move backward one word
:$ : move to the end of a line
:^/0 : move to the beginning of a line
:gg : go to the first line
:G : go to the last line
:nG : go to n line eg.1G
:set nu : set number line
:set nonu
CTRL + G : display the current line and total
CTRL + U : display up
CTRL + D : page down
delete copy and paste
d: delete
y: copy
p: paste
dd: delete a line eg.5dd
dw: delete a word
d0
d$: delete to end of line
yy: copy a line
yw:
y0:
y$:
:5, 10y: copy 5~10 line:p: paste
:.: repeat last operation
x: delete a character eg.3x
undo the editing
u/U: udo
CTRL + R: ned the modification
inset cursor
a/A: ater the cursor / end of a line
o/O: inout one new line under the current lin/ up the current line
help a
search
- /pattern : go to the pattern
- ?pattern:
- SHIFT +: match the word marked cursor
- number_line: go to the number line
replace
- :r/R: replace
- :%s/x/y/g: x change to y all of them
- :s/x/y/g: x change to y on the current line
- :10,23/x/y/g
file operation
- :sp: splite horizontally; put some files into one terminal
- CTRL + WW: change file in splite command
- :ZZ/q: quit a splite file
- :set diff: compara two files
other command
- :vsp: visual splite vertically
- :CTRL + V: visual mode
- :gf: go into file
- CTRL+ 0:return theoriginal file
- :J: merge the under line and the current lin eg. 3JA