How do I add, change, or delete surrounding characters with vim-surround?
Answer
cs"' (change), ds" (delete), ys iw" (add)
Explanation
The vim-surround plugin by Tim Pope adds commands for working with surrounding characters like quotes, brackets, and tags.
How it works
cs"'changes double quotes to single quotesds"deletes surrounding double quotesysiw"adds double quotes around a wordyss"adds quotes around the entire line
Example
Starting with "Hello world":
cs"'changes to'Hello world'ds'removes quotes:Hello worldysiw"onHello:"Hello" world
Tips
S"in visual mode wraps the selection in quotescs"<p>changes quotes to<p>tags- Works with
(,{,[,",',`, and HTML tags cst"changes surrounding tags to quotes- Install:
Plug 'tpope/vim-surround'