专辑:Vim 练级手册


Vim 插件 vim-surround 单词加环绕符号-LMLPHP

安装

Pathogen

1
2
$ cd ~/.vim/bundle
$ git clone https://github.com/tpope/vim-surround

Vundle

修改 ~/.vimrc

1
Plugin 'tpope/vim-surround'

在 Vim 中运行

1
:PluginInstall

使用

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
cs"'            # 替换 ==> "Hello world!" -> 'Hello world!'
cst" # 替换-标签(t=tag) ==> <a>abc</a>a> -> "abc"
cst<html> # 替换标签 ==> <a>abc</a>a> -> <html>abc</html>html>
ds" # 删除 ==> "Hello world!" -> Hello world!
ysiw" # 添加(ys=you surround) ==> Hello -> "Hello"
csw" # 添加 ==> Hello -> "Hello"
veeS" # 添加-两个词 ==> hello world -> "hello world"
ys$" # 添加-当前到行尾:
yss" # 添加-整行 ==> Hello world -> "Hello world"
ySS"
Hello world ->
"
hello world
"

# 左符号/右符号 => 带不带空格
cs([
(hello) -> [ hello ]

cs(]
(hello) -> [hello])
])
03-16 15:57