首页 > VIM > vim区域选择之motion特性

vim区域选择之motion特性

区域选择语法: <action>a<object> 或 <action>i<object>

action可以是任何的命令,如 d (删除), y (拷贝), v (可以视模式选择),c(修改)。
object 可能是: w 一个单词, W 一个以空格为分隔的单词, s 一个句字, p 一个段落。也可以是一个特别的字符:”、 ‘、 )、 }、 ]、<、>。PS:HTML标签编辑是不是会很爽 🙂

假设你有一个字符串 (map (+) (“foo”)).而光标键在第一个 o 的位置。

vi" → 会选择 foo.
va" → 会选择 "foo".
vi) → 会选择 "foo".
va) → 会选择("foo").
v2i) → 会选择 map (+) ("foo")
v2a) → 会选择 (map (+) ("foo"))


实际上区域选择语法用到了vim的”motion”特性,官方文档说明如下:
The motion commands can be used after an operator command, to have the command
operate on the text that was moved over. That is the text between the cursor
position before and after the motion. Operators are generally used to delete
or change text.
If the motion includes a count and the operator also had a count before it,
the two counts are multiplied. For example: “2d3w” deletes six words.

motion命令可以用在operator命令后面,实现在匹配的文本内容上执行特定命令.motion命令匹配指定标识符配对间的内容.
motion命令支持前缀数字表示匹配次数,当然operator与motion组合时也支持数字前缀,两个数字前缀将进行乘法效果.

 

引用资料:
分类: VIM 标签: , ,
  1. 直来直往
    2013年3月11日09:50 | #1

    区域选择语法: ai

  1. 本文目前尚无任何 trackbacks 和 pingbacks.

=1加9(必填)请输入两数相加的结果。