Change-inside-surroundings.vim

change-inside-surroundings.vim

:ChangeInsideSurrounding (also accessible via <leader>ci) - this will change the contents of the innermost 'surrounding'

:ChangeAroundSurrounding (also accessible via <leader>cas) - this will change the contents as well as the surrounding characters themselves

Examples

Vim already provides fairly easy ways to change the 'surrounding' as long
as you specify the opening 'surrounding' character. Vim also understands HTML
and XML tags, so you can change inside those as well. I wanted a single
command that would intelligently just do the right thing.

Normal Vim can do this:

Change inside an HTML tag:

Given: <div>London Calling</div>

To replace the contents of the div tag I can use: cit

Change inside curly braces:

Given: { death: "or glory!" }

To replace the contents of the curly braces I can use: ci{

Change inside brackets:

Given: [ Clampdown those Spanish Bombs ]

To replace the contents of the square brackets I can use: ci[

Change inside quotes:

Given: "The Guns of Brixton"

`To replace the contents of the quotes I can use: ci"

Change-inside-surroundings.vim makes this simpler

:ChangeInsideSurrounding or <leader>ci will remove the contents of the innermost 'surrounding', leaving you in insert mode.

:ChangeAroundSurrounding or <leader>cas will remove the entire text object, including the 'surrounding' characters, leaving you in insert mode.