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

posted @ 2017-04-25 18:09  吴佰清  阅读(8977)  评论(0编辑  收藏  举报