How to select between brackets (or quotes or ...) in Vim?

Rook picture Rook · Jun 30, 2009 · Viewed 103.8k times · Source

I'm sure there used to be a plugin for this kinda stuff, but now that I need it, I can't seem to find it (naturally), so I'll just ask nice and simple.

What is the easiest way to select between brackets, or quotes, or generally a list of matching characters?

   write ( *, '(a)' ) 'Computed solution coefficients:'

For example, here I'd like to select (a), or Computed solution coefficients:.

I'm not interested in multiline, just cases which occur on one line.

Answer

Christian C. Salvadó picture Christian C. Salvadó · Jun 30, 2009

To select between the single quotes I usually do a vi' ("select inner single quotes").

Inside a parenthesis block, I use vib ("select inner block")

Inside a curly braces block you can use viB ("capital B")

To make the selections "inclusive" (select also the quotes, parenthesis or braces) you can use a instead of i.

You can read more about the Text object selections on the manual, or :help text-objects within vim.