Contents

写代码的时候我们就会知道这个插件是多么的有用!!
~强烈的推荐~

0x01.change

1
2
3
4
5
cs"'
cs"<q>
cs)]
csw'
csW'
1
2
3
4
5
6
7
8
9
10
11
<!--more-->
文本 命令 结果
------------------ ------------- ---------------
"Hello |world!" cs"' 'Hello world'
"Hello |world!" cs"<q> <q>Hello world<q>
(123+4|56)/2 cs)] [123+456]/2
(123+4|56)/2 cs)] [ 123+456 ]/2
<div>foo|</div> cst<p> <p>foo</p>
fo|o! csw' 'foo'!
fo|o! csW' 'foo!'

0x02.adding
比如,我要把这个小标题用strong包括起来,再也不用想以前那么敲了,只需要:
yss<strong>

1
2
3
4
5
6
7
8
9
10
Text Command New Text
------------------ ------------- ----------------
Hello w|orld! ysiw) Hello (world)!
Hello w|orld! csw) Hello (world)!
fo|o ysiwt<html> <html>foo</html>
foo quu|x baz yss" "foo quux baz"
foo quu|x baz ySS" "
foo quux baz
"
(| is the position of cursor in these examples)

0x03.delete
ds

全部的命令和快捷键参考:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Normal mode
-----------
ds - delete a surrounding
cs - change a surrounding
ys - add a surrounding
yS - add a surrounding and place the surrounded text on a new line + indent it
yss - add a surrounding to the whole line
ySs - add a surrounding to the whole line, place it on a new line + indent it
ySS - same as ySs
Visual mode
-----------
s - in visual mode, add a surrounding
S - in visual mode, add a surrounding but place text on new line + indent it
Insert mode
-----------
<CTRL-s> - in insert mode, add a surrounding
<CTRL-s><CTRL-s> - in insert mode, add a new line + surrounding + indent
<CTRL-g>s - same as <CTRL-s>
<CTRL-g>S - same as <CTRL-s><CTRL-s>

vim插件—surround.vim

Contents