# Quickly go to the end of “syntax highlighted” element

I am using syntax highlighting to help with writing LaTeX documents in vim. My documents involve a lot of brackets, and it is easy to do a trivial mistake and end-up with something which doesn't compile; though it can be fixed, it wastes a lot of time.

Question : Is there any way to jump to the end/start of the highlighted pair? In the following picture \left\{ is recognised as a partner for \right\}, how to go to anywhere near (start or end or middle) of \right\} if the cursor is on :

• \left\{

• somewhere between \left\{ and \right\}

Edit : As per comments -

+\sqrt{\frac{i}{2}} \sqrt{\frac{i-1}{2}} \left\{ e^{i t_{1} E_{i,i-1}} e^{i t_{2} E_{i-1,i}} - e^{i t_{2} E_{i,i-1}} e^{i t_{1} E_{i-1,i}} \right\} - \sqrt{\frac{i}{2}} \sqrt{\frac{i-2}{2}} \cancelto{0}{\left\{ e^{i t_{1} E_{i,i-1}} e^{i t_{2} E_{i-1,i-2}} - e^{i t_{2} E_{i,i-1}} e^{i t_{1} E_{i-1,i-2}} \right\}} \\


• Hi and welcome! I think matchit (:h matchit) might work. It gives you the ability to jump between matching 'groups' with %. Besides, could you post your first image as text? It'd be more readable (and I could copy to test on it). – Biggybi May 28 at 12:49
• Seconded: please dont post images of text – D. Ben Knoble May 28 at 12:58
• @Biggybi Added the text in edit. I am trying with matchit and if I can make it work, will update here. – Nitin May 28 at 13:31
• @D.BenKnoble Thank you. Will keep this in mind from now on! – Nitin May 28 at 13:31
• @Nitin Vim's help for 'matchit' calls them 'matching groups', although 'partner tags' is pretty descriptive in my opinion. – Biggybi May 28 at 13:38

You can use the matchit plugin for this. It supports many languages, and seem to work great with LaTeX.

It allows you to use % to jump between matching tags.

To install it, you can simply add this line to your vimrc file:

packadd! matchit


Or instal from the repo with your favourite plugin manager.

• Thanks. I am a little confused : what's the role of matchit here? % seems to work whether or not I am using matchit. I disabled the packadd! matchit command from my vimrc and still % seems to work just fine! – Nitin May 28 at 13:47
• Oh, well. Basically, it 'unlocks' more pairs. In :h % is a note about this :) – Biggybi May 28 at 13:52
• Yes @Nitin matchit allows a “pair” to be, for example, if/elseif/else/endif as opposes to just just brackets – D. Ben Knoble May 28 at 13:55
• Perfect! Thanks guys :) – Nitin May 28 at 14:03