VIM basic operations

1) modes:

modekeydescription
General Mode<ESC> 
Insert Modeibegin at current cursor place
 abegin at the following character position
 Abegin at the end of this line
 oget a new line below
 Oget a new line above
 ceremove the following characters of the word the cursor points to
Replace ModeRreplace all, r can replacethe current character
Visual Modev 
Visual BlockModeCtrl + v 

2) General Mode:

2.1) move cursor
)                  (k)KongMiao
)                             |
)   (h)HeNan -------------- (l)Angeles
)                             |
)                      (j)Java

keydescription
wmove cursor forward to the front of the next word
emove cursor forward to the tail of the next word
Nwmove cursor forward N words(to the start of a word
Nemove cursor forward N words(to the end of a word
0move cursor to the start of this line
$move cursor to the end of this line
ggmove cursor to the start of this file
Gmove cursor to the end of this file
Ctrl+ gshow where the cursor is and the file state

2.2) delete contents

keydescription
xdelete acharacter
d2wdelete 2 words
dwdelete aword(including whitespace)
dedelete aword(excluding whitespace)
dddelete a line
2dddelete 2 lines
Jdelete '\n' ofcurrent line
d$delete all the following characters of this line

2.3) move contents
descriptiondetailed-descriptionkey
move words/lines (deletecontents) + p(paste)
copy words/linescopy blocksv(visual mode) + move cursor + y(yank, copy) + p(paste)
copy words/linescopy wordyw(yank word) + p(paste)

2.4) undo and redo
descriptionkey
undou
redo(undo undo)Ctrl +r
undo alloperations for this lineU
2.5) search commands
descriptionkey
search the wordthe cursor points toShift+ *
search forward/xxxx
search backward?xxxx
search andignore case once/xxxx/c
jump to the nexthit targetn
jump to theprevious hit targetN
return to previousCtrl + o
return to nextCtrl + i
2.6) customize search rules
descriptionkey
set ignore case:setic
set hlsearch andincsearch:sethls is
set no ignorecase:setnoic
remove highlightsearch:setnohlsearch
ignore caseonce/xxxx/c
2.7) help
descriptionkey
vimdocumentation help:help
exit helpZZ
enter hyperlinkCtrl+ ]
exit hyperlinkCtrl+ t, Ctrl + o
shell commandvimtutor

2.8) shell command related

descriptiondetailed-descriptionkey
retrive and merge filesretrive contents in file A and insert it to the next line of theposition the cursor points to:rfileA
retrive and merge filesretrive result of a commandA execution and insert it to the next line of theposition the cursor points to:r!commandA
execute external command :!command (shellcommand)
 write to a specific fileF:w fileF
 remove a specific fileF:rm fileF
 write the seleted contentsto a specific fileFv (movecursor) :w fileF

2.9) visual block insert(useful when annotating source code):

Ctrl + v(enter visual blockmode), I + characters(insert), <ESC>

2.10) vsplit
descriptiondetailed-descriptionkey
open another fileF :vsplitfileF
switch between windows Ctrl+ ww
equalize window size Ctrl+ W, =
vertical resize window sizespecify size:vertical resize N(pixels)
 increase/decrease size:Ctrl+ W, </>
horizontal resize window sizespecify size:resize N(pixels)
 increase/decrease size:Ctrl+ W, +/- N(pixels)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值