vim tpope/vim-surround Cheat Sheet

A Software › Vim cheat sheet in English by mutanclan

Shortcuts for tpope's vim-surround plugin

28,967 views 2,733 downloads 9 Apr 2019 History
3.7 avg · 0 ratings

Delete surrou­ndings

ds
delete surrou­nding
ds"
delete surrou­nding "
ds)
delete surrou­nding ()
dst
delete surrou­nding (html)tag
Examples

Visual mode

S"
surround selected text with "
S<p>
surround selected text with <p> ... </p>
Examples in visual mode

Targets

The |ds| and |cs| commands both take a target as their first argument.  The
possible targets are based closely on the |text-objects| provided by Vim.
All targets are currently just one character.

(, ), {, }, [, ], <, and >
The targets b, B, r, and a are aliases for ), }, ], and >
 ', ", `,
A t is a pair of HTML or XML tags.

The letters w, W, and s correspond to a |word|, a |WORD|, and a |sentence|. A p represents a |paragraph|

Change surrou­ndings

cs"'
change surrou­nding " to '
cs"<­q>
change surrou­nding " to <q>some text</q>
cst<p>
change surrou­nding tag with <p>
cs)]
change surrou­nding () to []
cs)[
change surrou­nding () to [] with spaces
Examples

Create surrou­ndings

ysiw)
add surrou­nding () to inner word
yss]
add surrou­nding [] to whole line, without leading whitespace
Examples

functions

ysWfpr­int­<cr>
wraps old text into a function print
ysWFpr­int­<cr>
wraps a WORD into a function print with spaces

Badges

Nice Cheat Sheet

Comments

No comments yet.

Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.