Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save brownfoxsir/490c3cc20b6d587d30546f44e2603ff1 to your computer and use it in GitHub Desktop.
Save brownfoxsir/490c3cc20b6d587d30546f44e2603ff1 to your computer and use it in GitHub Desktop.
vim-surround使用指南,vim-surround如何使用

普通模式

命令 说明 + 示例
ds 删除括号
ds " "Hello world!" =>
Hello world!
cs 替换括号
cs "( "Hello world!" =>
(Hello world!)
cS 替换括号,括号内文本做新一行
cS "{ "Hello world!" =>
{
    Hello world!
}
ys 添加括号(配合vim光标移动)
ys w [ Hello world! =>
[Hello] world!
ys w <em Enter Hello world! =>
<em>Hello<em> world!
yS 添加括号,括号内文本做新一行
yS w [ Hello world! =>
[
     Hello
] world!
yss 整行括起来
yss ( Hello world! =>
( Hello world! )
ySS 整行括起来,括号内文本做新一行
ySS { Hello world! =>
{
   Hello world!
}
ySS <div Enter Hello world! =>
<div>
   Hello world!
<div>
ySs 与ySs功能相同

可视模式

命令 说明 + 示例
S 选中的括起来
选中world: S( Hello world! =>
Hello (world)!
gS 选中的括起来,括号内文本做新一行
选中world: gS{ Hello world! =>
Hello {
   world
}!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment