vim-surround README

The project's README from github.com/tpope/vim-surround. As one markdown file: README.md.

surround.vim

Surround.vim is all about "surroundings": parentheses, brackets, quotes, XML tags, and more. The plugin provides mappings to easily delete, change and add such surroundings in pairs.

It's easiest to explain with examples. Press cs"' inside

"Hello world!"

to change it to

'Hello world!'

Now press cs'<q> to change it to

<q>Hello world!</q>

To go full circle, press cst" to get

"Hello world!"

To remove the delimiters entirely, press ds".

Hello world!

Now with the cursor on "Hello", press ysiw] (iw is a text object).

[Hello] world!

Let's make that braces and add some space (use } instead of { for no space): cs]{

{ Hello } world!

Now wrap the entire line in parentheses with yssb or yss).

({ Hello } world!)

Revert to the original text: ds{ds)

Hello world!

Emphasize hello: ysiw<em>

<em>Hello</em> world!

Finally, let's try out visual mode. Press a capital V (for linewise visual mode) followed by S<p class="important">.

<p class="important">
  <em>Hello</em> world!
</p>

This plugin is very powerful for HTML and XML editing, a niche which currently seems underfilled in Vim land. (As opposed to HTML/XML inserting, for which many plugins are available). Adding, changing, and removing pairs of tags simultaneously is a breeze.

The . command will work with ds, cs, and yss if you install repeat.vim.

Installation

Install using your favorite package manager, or use Vim's built-in package support:

mkdir -p ~/.vim/pack/tpope/start
cd ~/.vim/pack/tpope/start
git clone https://tpope.io/vim/surround.git
vim -u NONE -c "helptags surround/doc" -c q

FAQ

How do I surround without adding a space?

Only the opening brackets—[, {, and (—add a space. Use a closing bracket, or the b (() and B ({) aliases.

Contributing

See the contribution guidelines for pathogen.vim.

Self-Promotion

Like surround.vim? Star the repository on GitHub and vote for it on vim.org.

Love surround.vim? Follow tpope on GitHub and Twitter.

License

Copyright (c) Tim Pope. Distributed under the same terms as Vim itself. See :help license.

vim-surround (tpope/vim-surround)

Searching Database…

这是什么?一个 Vim 插件,添加映射,用于删除、修改和添加成对的包围符号,比如圆括号、方括号、引号以及 XML/HTML 标签。
这是独立应用还是 Vim 插件?它是一个 Vim 插件(编辑器脚本),不是独立应用程序,只能在 Vim 里使用。
用它之前还需要安装别的插件吗?使用核心映射不需要任何依赖,但安装 repeat.vim 后,点号(.)就能重复 ds、cs 和 yss 操作。
怎样包围文本又不多加空格?使用左括号((、{ 或 [)时,内侧会加空格;要避免空格,请改用右括号,或者使用 b/B 别名。
有哪些基本命令需要先学?ds 删除一对包围符号,cs 把一对符号改成另一对,ys/yss 则在某个移动范围或整行周围添加包围符号;在可视模式下,S 可以包围选中的内容。
用它编辑 HTML 或 XML 标签好用吗?好用。README 称它在 HTML/XML 编辑方面非常强大,因为可以一次性添加、修改和删除成对的匹配标签;作者还提到,这一领域在 Vim 中尚未得到充分发展。
Creator
tpope
Size
0.1 MB
Stars
14.1K
Updated
CommitOct 25
Age
18y
Commits · 90 Days