0%

Vim-surround备忘录

一切的一切都要怪我根本记不得vim-surround的那些命令,以至于需要用的时候都得读readme,太丑陋了,所以找点时间梳理一下下。

vim-surround可以在normal模式下用,也可以在visual模式下用。

normal

根据第一个字母的区别,分为三种:

  • ys: yield surrounding,带一个参数(下同)
    • yss: yield the surrounding of the whole line
    • ys$: yield the surrounding of the interval from current cursor to end of line
    • ysiw: yield the surrounding of the next word
    • ys2w: yield the surrounding of the next 2 words (generalized to n, including 1)
  • ds: delete surrounding,带一个参数(下同)
  • cs: change surrounding,带两个参数(下同)

其实如果在vim里面点开:man

visual

visual模式下使用比较单一,只能够选择区间,然后在两边添加,而不能删除或更改。(如果需要直接在normal模式操作了)

操作的方式很简单,先选区间,然后按S,后面跟一个参数即可。

参数

  • 各类括号的左半边
  • 各类括号的右半边
  • t: 已存在的xml的tag的指代

总结的不全,但是已经足够日常使用了。