I am within a vimscript, and I want jump (or get the position of) the beginning of the current parent brace, how can I make this happen?

Imagine the following example (the cursor is represented by |):

  (a   &&   (b && c)   &&   | (d && e))     <- For parentheses
  [a   &&   [b && c]   &&   | [d && e]]     <- For square brackets
  {a   &&   {b && c}   &&   | {d && e}}     <- For curly braces
  <a   &&   <b && c>   &&   | <d && e>>     <- For angle brackets
  ^                         ^
parent (jump here)        cursor

I know that there are the [{ and [( commands, but they only jump to a { and (, and not to [ and <. Also I need some kind of way to jump to any parent bracket, not a specific type of one.

Thank you for your help.

  • What is the concrete scenario that leads to this problem? Why do you need to jump to the parent bracket at all?
    – jdhao
    Commented Dec 9, 2020 at 8:02

2 Answers 2


This functionality is provided by standard "matchit" plugin (if running Vim make sure you've enabled it with packadd matchit).

Press [% to get to the previous unmatched bracket. Don't forget to add < and > to :h 'matchpairs' as it's not the default.

Read :h matchit for more info.


You can always use

call searchpair('<', '', '>', 'bW')

To search for arbitrary pairings.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.