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 severa
(defun px-match-paren (arg)
"Go to the matching paren if on a paren; otherwise insert <key>."
(interactive "p")
(cond
((char-equal 41 (char-before)) (backward-list 1))
((char-equal 125 (char-before)) (backward-list 1))
((and
(char-equal 123 (char-before))
(char-equal 10 (char-after)))
(backward-char 1) (forward-list 1))
((looking-at "\\s\(") (forward-list 1))
((looking-at "\\s\)") (backward-list 1))
(t (self-insert-command (or arg 1)))))
The <key>
to witch you bind this command will toggle opening and closing brace if point is before or after it, otherwise insert <key>
(much like vi's "%")
I also bind C-<key>
to forward-sexp
and C-S-<key>
to backward-sexp
so I can really quickly navigate through functions in the file.
Try mic paren which shows matching parenthesis code even if found outside the present screen.
backward-sexp is what I use. bound to ESC-left. Then ESC-right to get back to where you were
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.