Brad
Brad

Reputation: 11505

Select progressively "inner" and/or "outer" code blocks in vim

I can use vim commands like va} or vi] to automatically select everything within parentheses, brackets, etc.

Once I have such a selection, is there a way to then select the next outermost selection of that type? (Then from there, back to the next "innermost"?)

I am 99.9% sure I used to know how to do this - but can't find it or figure it out anywhere!

Upvotes: 33

Views: 10666

Answers (2)

qqx
qqx

Reputation: 19475

Just repeat the object selection keys. For your examples this would be va}a} or vi]i].

I don't think that there is a way to then reduce the selection back to an inner block. Other than to use Esc to clear the selection, `` to jump back to your starting point and then redo the initial selection.

Upvotes: 47

thalesmello
thalesmello

Reputation: 3439

I know it's a little bit outdated, but are you talking about the vim-expand-region plugin?

Anyways, I still prefer qqx's way, since it's already built-in.

Upvotes: 2

Related Questions