Vim常用操作-快速刪除括號中內(nèi)容。

如果你和我一樣,希望擁有眾多工具,發(fā)揮工具最大執(zhí)行效率,讓工作事半功倍的話,我推薦你來使用下 Vim。
剛接觸Vim 會覺得它的學(xué)習(xí)曲線非常陡峭,要記住很多命令,操作太復(fù)雜。所以這個系列的分享,不會教你怎么
配置它,而是教你怎么快速的掌握它。
學(xué)不會就不要繼續(xù)學(xué)了,直接拿來用就好了。
接下來我們要實現(xiàn)這種效果,快速的刪除括號中的內(nèi)容。

操作步驟:
1. 按 ESC 進(jìn)入 Normal 模式,通過 h 左、j 下、k 上、l 右 來控制光標(biāo),把光標(biāo)移動到括
號中。
2. 連續(xù)按 di( 就可以把括號中的內(nèi)容刪除了。
剛才連續(xù)按下的快捷鍵,代表的意思是 delete all content inside ( 所以結(jié)果字符串為 ()
更多案例:
比如說有這么個字符串 "testdfat",假設(shè)光標(biāo)停留在第一個 t 位置。
di":delete all content inside ",結(jié)果字符串為""
dta:delete all content to a,結(jié)果字符串為"at"
dfa:delete all content from current location, until a is found,結(jié)果字符串為"t"
高手進(jìn)階:
i 表示 inside,打開 Vim 后,執(zhí)行 :help object-select 可以看詳細(xì)介紹。
This is a series of commands that can only be used while in Visual mode or
after an operator. The commands that start with "a" select "a"n object
including white space, the commands starting with "i" select an "inner" object
without white space, or just the white space. Thus the "inner" commands
always select less text than the "a" commands.
These commands are {not in Vi}.
These commands are not available when the +textobjects feature has been
disabled at compile time.
Also see gn and gN, operating on the last search pattern.
相關(guān)學(xué)習(xí):
Vim 模式:http://www.rzrgm.cn/zeushuang/archive/2012/11/16/2772830.html

浙公網(wǎng)安備 33010602011771號