Vim: Select text between brackets including new line character

Solution 1:

There is no dedicated way to achieve that.

Here is how I do it:

caB{}<Esc>

But you could do it like this:

diBkJx

or like this:

gwiBdiB

or possibly a dozen other ways.

You can map it to something easier for the fingers if you need to do that often.

Reference:

:help c
:help aB
:help d
:help iB
:help k
:help J
:help x
:help gw

---EDIT---

FWIW, I've been puzzled by that behaviour for years.

I think the core of the issue is that there is no text after the { on the same line and no text before the } on the same line, but which character seems important.

import {___(3 spaces)  If you append characters of _any_ kind to {,
  one,                 including whitespace, then the selection
  two,                 includes them.
} from "../myfile";

import {xxx
  one,
  two,
} from "../myfile";

append whitespace append non-whitespace

import {xxx            If you prepend whitespace characters to },
  one,                 then they are ignored.
  two,
  } from "../myfile";

prepend only whitespace

import {xxx            If there is even _one_ non-whitespace
  one,                 character in those prepended to },
  two,                 then the selection includes them all.
 x } from "../myfile";

prepend mixed characters

I am really not sure about the rationale, here.