Skip to content

Instantly share code, notes, and snippets.

@wilon
Last active December 17, 2024 22:06
Show Gist options
  • Save wilon/ac1fc66f4a79e7b0c161c80877c75c94 to your computer and use it in GitHub Desktop.
Save wilon/ac1fc66f4a79e7b0c161c80877c75c94 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
}!
@c1ay
Copy link

c1ay commented Jun 20, 2019

这是我独享的moment

@mysteryven
Copy link

awesome

@llh3719
Copy link

llh3719 commented Oct 18, 2019

有好多常用的用法,太感谢了

@chengpengzhao
Copy link

这个插件确实不错

@suica
Copy link

suica commented Oct 13, 2021

牛逼

@suica
Copy link

suica commented Jun 17, 2022

牛逼

@6mad
Copy link

6mad commented Jun 22, 2022

mark!

@gowk
Copy link

gowk commented Dec 21, 2022

遇见大S就失效咋回事呢

@linghutf
Copy link

mark

@linyanm
Copy link

linyanm commented May 31, 2023

awesome! 可惜vscode的vim surround好像没有实现大S的功能

@brownfoxsir
Copy link

好用

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment