是否有一个 vim 命令将光标移动到父括号?

是否有一个 vim 命令将光标移动到父括号?

我有一个像这样的配置文件,我想直接转到父括号。有没有一个简单的移动命令可以做到这一点,或者有没有一种方法可以组合命令来做我想做的事情?

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... }
}
36044 次浏览

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

Many move commands are available at :help [.

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

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