Use nvim-surround core operations
mainThe plugin provides three core operations: adding, deleting, and changing surrounding pairs using specific keymap patterns.
Keymap Patterns:
- Add:
ys{motion}{char} - Delete:
ds{char} - Change:
cs{target}{replacement}
Delimiter Behavior:
- Surrounding with an opening delimiter (e.g.,
() adds a space before and after the selection. - Surrounding with a closing delimiter (e.g.,
)) does not include spaces.
Old text Command New text
--------------------------------------------------------------------------------
surr*ound_words ysiw) (surround_words)
surr*ound_words ysiw( ( surround_words )
*make strings ys$" "make strings"
[delete ar*ound me!] ds] delete around me!
remove <b>HTML t*ags</b> dst remove HTML tags
'change quot*es' cs'" "change quotes"
<b>or tag* types</b> csth1<CR> <h1>or tag types</h1>
delete(functi*on calls) dsf function calls