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

Vim

Vim Problem Overview


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... }
}

Vim Solutions


Solution 1 - Vim

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

Many move commands are available at :help [.

Solution 2 - Vim

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

Solution 3 - Vim

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...)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionB JohnsonView Question on Stackoverflow
Solution 1 - VimBenoitView Answer on Stackoverflow
Solution 2 - VimRusAlexView Answer on Stackoverflow
Solution 3 - VimevadeflowView Answer on Stackoverflow