Surround is a useful Vim plugin when hand-editing HTML or XML. The plugin can be downloaded via Github or the Vim website and installed by copying the
/plugin/surround.vim file to your
~/.vim/plugin/ directory. A few of its basic commands are as follows. Note that each command is entered from within the text to be surrounded:
ys commands can be used to add surroundings.
<tag> or Puncation to Word:
Add Surrounding to Highlighted Text From Within Visual Mode:
<tag> or Punctuation to Line:
Add Surrounding to Line, Place it on a New Line, and Indent It:
Surroundings can be changed with the cs command.
Change Surrounding Puncuation, in this Case Changing a Double Quote to a Single Quote:
Delete Innermost Surrounding
Delete Surrounding Quotes (Also works with parentheses, brackets, etc.):
Delete Text Within a
While this isn’t a function of Surround.vim, I find it somewhat relevant to the above operations. Luckily, it’s built into Vim.