Delete everything between two brackets in Vim, including newlines
You can simply do:
ca[[]<Esc>
or:
ca][]<Esc>
See :help text-objects
.
With your cursor on the first opening bracket ([
), press V
, followed by %
. This will select the block which you then can join J
, followed by di[
.
Select the lines in visual mode (v
) and use J
to remove newlines. Then use di[
.
Or if there are many lines, di[
first, after which you move the cursor to top line and then J
. This will potentially leave a space between the brackets which has to be removed with x
.