vim 常用
模式:
正常模式
插入模式:i
可视模式:v
命令模式: ':'进入命令模式; \ or ? 进入搜索
1.光标移动:
单个字符:
H(left) J(donw) K(up) L(right)
行首行尾:
<S-^>(line begin) <S-$>(line end)
<HOME> <END>
向前向后跳转一个单词:
w: word forward
b:words backward
移动上一句和下一句
<S-}> or <S-{>:上一段 or 下一段
<S-)> or <S-(>:上一句 or 下一句
移动到文章开头和结尾:
<gg>: 文章开头
2. 文本修改:
delete:
<dd>: delete a line ;
<D>: d$. delete to the end of line;
edit:
<cc>: delete current line and enter insert model
<C>:c$. delete from current to end and enter insert model.
<s>:cl. delete current char and enter insert model
<S>:cc. delete this line and enter insert model
<i>:i. insert before current char
<I>:^i. move to the begin of line and enter insert model
<a>: insert after current char.
<A>:$a. move to end of line and enter insert model
<o>: insert a new line after this line and enter insert model
<O>: insert a new line before this line and enter insert model
<r>: replace this char
<R>: enter replace model.
<u>: revoke last action.
<U>: revoke this line change.
3. 文本对象选择【例:if(message == "sesame open"),光标在ame的a上】
<dw>: delete word. delete ame_
<diw>:delete inside word. delete sesame
<daw>:delete a word. delete sesame_
<diW>:delete inside word and char. delete "sesame
<daW>:delete a word and char. delete "sesame_
<di">:delete sesame open
<da">:delete "sesame open"
<di(>:delete message == "sesame open"
<da(>:delete (message == "sesame open")
4. 更快的移动
<C-F>:next page.
<C-B>:last page.
<C-U>:next half page.
<C-D>:last half page.
<numG>: jump to [n] line.
<num|>:jump to [n] column.