Tuesday, August 9, 2016

Papeeria News, Aug 9: Bracket Matcher

TL;DR: use Ctrl+Chift+9 to highlight matching and non-matching brackets closest to the cursor position.

Missing bracket might be a real nightmare when editing LaTeX documents. Should you miss one curly bracket, and your document is not compiling and you see something like this in the logs:

Runaway argument?
{\emph {itemnum} that makes little sense when hyphenated across lines\ETC.
! File ended while scanning use of \mbox.
<inserted text> 
                \par 
<*> main.tex
            
I suspect you have forgotten a `}', causing me
to read past where you wanted me to stop.
I'll try to recover; but if the error is serious,
you'd better type `E' or `X' now and fix your file.

! Emergency stop.
<*> main.tex
            
*** (job aborted, no legal \end found)

It is not easy to spot the place where missing bracket is supposed to be, despite that TeX tries to give you a clue. Now in Papeeria you can use Bracket Matcher tool which will make your life easier.

Hit  Ctrl+Shift+9  (Cmd+Shift+9 on Mac) to switch Bracket Matcher mode on. When running, Bracket Matcher searches for the closest pair of matching brackets around the cursor. If it finds such pair, it highlights the region between them with light blue color.

Bracket Matcher highlighting matching curly brackets around cursor
However, if it finds a mismatch, e.g. because there is an opening bracket and no corresponding closing bracket or if opening and closing brackets are different (have you ever mistyped square bracket  ]  instead of curly bracket  }  ?), it highlights the region with rose color. 

Bracket Matcher highlighting mismatched region

Bracket Matcher rebuilds the highlight as cursor moves, so you can quickly find where exactly you missed the bracket. You can switch Bracket Matcher off using the same shortcut  Ctrl+Shift+9  

Thanks to our summer intern Mikhail Pochatkin who contributed a lot of energy into the development of this feature!


No comments:

Post a Comment