您的位置:首页 > 其它

常用基础Vim命令

2013-08-06 09:30 190 查看
最近学习Ubuntu,时常需要用Vim来查看和编辑文件,整理出下列常用的命令作为备忘录。

完整版的Vim Manual可以在 这里 找到, 也可以在打开vim之后输入命令 “:help” 来查看。

左侧是命令,右侧是简单的命令说明,在左侧的命令中 N一般都代表输入命令前可以输入的数字。

Move Command

N hMove to left
N lMove to right
0Move to line start
^Move to first non-blank character in the line
$Move to line end
gmMove to the middle of the screen line
N |Move to column N, default to column 1
N kMove to N lines up
N jMove to N lines down
GMove to the last line
ggMove to the first line
N %Move N percentage down in the file, N must be given
CTRL-FPage downwards
CTRL-BPage upwards
z<CR>redraw, current line at top of window
z.redraw, current line at center of window
z-redraw, current line at bottom of window

Search Command

/{pattern}Search forward for the {pattern}
?{pattern}Search backward for the {pattern}
nRepeat last search
NRepeat last search in opposite direction
*Search forward for the identifier under the cursor
#Search backward for the identifier under the cursor

Insert Command

aappend text after the cursor
Aappend text at the end of the line
iinsert text before the cursor
Iinsert text before the first non-blank in the line
N oopen a new line below the current line, append text N times
N Oopen a new line above the current line, append text N timesjj

Undo and Redo

uundo last change
CTRL-Rredo last undone changes
Urestore last changed line

Other

CTRL-Gshow current file name with path and cursor position
ga show ascii value of character under cursor in decimal, hex and octal
g8show utf-8 encoding: show byte sequence for character under cursor in hex
g CTRL-Gshow cursor column, line and character position
CTRL-Cduring searches: Interrupt the search
CTRL-W ssplit to two window
CTRL-W jmove to window below
CTRL-W kmove to window above
q!quit vim and discard all changes
wqquit vim and save all changes
wsave changes
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: