In GNU Emacs there is a feature to highlight matching brackets in code with the same colour.
However when the code which the brackets enclose is really long with several nested if's for's etc. then this feature is not really useful since one of the brackets will not be visible.
Say I have the following,
for(int i=0; i< N; ++i)
{
/*Long code*/
}
If my cursor is on the }
brace I would like to have some feature which will enable me to jump / see the {
brace, and then , if satisfied, come back to the }
brace for any future coding.
Is this possible in Emacs?
This is actually a very standard binding: C-M-f
and C-M-b
to go back and forwards by default. In most modes C-M-f
will take you forwards to the matching brace and C-M-b
will take you backwards to the matching brace. This also works for things like quotes, pretty much the same way.
These bindings are easy to remember if you already use C-f
and C-b
for navigation. (If you don't, you should.) They're just like moving forward and backwards by a character lifted to moving by expression (which depends on mode).
The first thing that might help is knowing about this option, if you don't already: blink-matching-paren-distance
. If the sexp is very large then you need to increase the option value, or else paren matching gives up too soon and it shows a mismatch when there is no mismatch.
The second thing that can help is to be sure that blink-matching-paren
and blink-matching-paren-on-screen
are both non-nil
. Then, to see the opening delimiter, just delete the closing delimiter and then type it again. When you insert it, the opening one will be made evident.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With