Delete everything between two brackets in Vim, including newlines

vi, vim

Solution

You can simply do:

ca[[]<Esc>

or:

ca][]<Esc>

See `:help text-objects`.

Problem

Say I have the following python array literal: ``` def f(): arr = [ 1, 2, 3 ] ``` I want to delete everything in the brackets so that it becomes this: ``` def f(): arr = [] ``` How can I do that with minimal commands in vim? These are some of my attempts: Using `di]` will delete the text, but not the empty newlines, leaving a lot of whitespace I'd have to delete: ``` def f(): arr = [ ] ``` Using `da]` will delete the newlines, but also the brackets: ``` def f(): arr = ```

Original source