Vim常用操作-快速刪除括號中內容。


如果你和我一樣,希望擁有眾多工具,發揮工具最大執行效率,讓工作事半功倍的話,我推薦你來使用下 Vim。

剛接觸Vim 會覺得它的學習曲線非常陡峭,要記住很多命令,操作太復雜。所以這個系列的分享,不會教你怎么

配置它,而是教你怎么快速的掌握它。

 

學不會就不要繼續學了,直接拿來用就好了。

 

接下來我們要實現這種效果,快速的刪除括號中的內容。

 

操作步驟:

1. 按 ESC 進入 Normal 模式,通過 h 左、j 下、k 上、l 右 來控制光標,把光標移動到括

號中。

2. 連續按 di( 就可以把括號中的內容刪除了。

剛才連續按下的快捷鍵,代表的意思是 delete all content inside ( 所以結果字符串為 ()

 

更多案例:

比如說有這么個字符串 "testdfat",假設光標停留在第一個 t 位置。

di":delete all content inside ",結果字符串為""

dta:delete all content to a,結果字符串為"at"

dfa:delete all content from current location, until a is found,結果字符串為"t"

 

高手進階:

i 表示 inside,打開 Vim 后,執行 :help object-select 可以看詳細介紹。

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.

 

相關學習:

Vim 模式:http://www.cnblogs.com/zeushuang/archive/2012/11/16/2772830.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM