Github url

vim-surround

by tpope

tpope /vim-surround

surround.vim: quoting/parenthesizing made simple

8.3K Stars 337 Forks Last release: Not found 113 Commits 3 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

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></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
_Hello_ world!

Finally, let's try out visual mode. Press a capital V (for linewise visual mode) followed by

S

.

_Hello_ world!

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 installrepeat.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

Contributing

See the contribution guidelines forpathogen.vim.

Self-Promotion

Like surround.vim? Star the repository onGitHub and vote for it onvim.org.

Love surround.vim? Follow tpope onGitHub andTwitter.

License

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

:help license

.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.