Is there a quick way to delete brackets ( some string )
and then select "some string"?
ds(
deletes them (using the surround
plugin). vi(
selects but only when they exist.
looking for normal mode.
vi(<Esc>ds(gvhoh
Breakdown:
vi(
selects visual region within the brackets using the surround plugin.<Esc>
stops the visual selection mode.ds(
deletes the surrounding brackets using the surround plugin.gv
restarts visual selection mode with the most recent visual selection, however it's tripped by the now missing brackets and the selection is shifted to the right by one character i.e. length of first surrounding character, here the (
. h
begins correcting the original position of the visual selection by moving the right edge of visual selection leftwards by one character.o
transports cursor to the other end of the visual selection.h
moves the left edge of visual selection leftwards by one character.Essentially this solution is based on gv
which reselects the most recent visual selection. You can adapt the rest of the key sequence to take care of any edge cases like if located at the end of line, or length of surrounding characters being more then 1 and uneven lengths, for e.g. html tags like <strong></strong>
etc.
( some string )
is in a single line, then the markers`[
and`]
will mark the start and end of the expression, so you could use`[v`]
to select it. Unfortunately, that doesn't work when the expression spawns multiple lines...