Basic Overview of the Surround Plugin for Vim
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:
Generally, the cs or ys commands can be used to add surroundings.
1 2 ysiw<tag> csw<tag>
Add Surrounding to Highlighted Text From Within Visual Mode:
Add Surrounding to Line, Place it on a New Line, and Indent It:
1 2 ySs<tag> ySS<tag>
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.