常用基础Vim命令

最近学习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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值