B Johnson
B Johnson

Reputation: 2566

Is there a vim command to move the cursor to the parent bracket?

Is there a vim command to move the cursor to the parent bracket?

I have a configuration file like this one, and I want to go straight to the parent bracket. Is there a simple movement command to do this, or is there a way to combine commands to do what I want?

PARENT{ // I want to move my cursor here

   CHILD { stuff... }
   CHILD { stuff... }
   CHILD { stuff... }

...

   CHILD { stuff... } // my cursor is on this line
   CHILD { GRANDCHILD { more stuff } }
   CHILD { stuff... }
}

Upvotes: 123

Views: 53402

Answers (3)

evadeflow
evadeflow

Reputation: 4944

It looks like [[ does what you want. And ][ moves to the bottom-most brace. (With many thanks to @Benoit for cluing me in that this might be possible...)

Upvotes: 11

RusAlex
RusAlex

Reputation: 8585

Also you can press % and it will show your open or close bracket

Upvotes: 67

Benoit
Benoit

Reputation: 79235

Yes. Do [{ in normal mode for that. It might not work for all languages though.

Many move commands are available at :help [.

Upvotes: 205

Related Questions