I generally prefer AucTeX over the built-in tex-mode, but one thing that is much better in tex-mode is navigation by s-expression. Namely, in tex-mode, forward-sexp
(C-M-f
) treats LaTeX environments as s-expressions; with the point right before \begin{foo}
, forward-sexp
will take you to after the corresponding \end{foo}
. Other sexp based functions also do the right thing, for example backward-up-list
(C-M-u
) will take you to the enclosing \begin{foo}
.
How can I get this functionality in AucTeX?
(I noticed tex-mode defines a latex-forward-sexp
and sets forward-sexp-function
to that function. I tried loading tex-mode after AucTeX and evaluating (setq-local latex-forward-sexp #'latex-forward-sexy)
but that didn't seem to change the behavior of forward-sexp
in the AucTeX buffer.)
LaTeX-find-matching-begin
(C-M-a
) andLaTeX-find-matching-end
(C-M-e
). Have you tried them? – Arash Esbati Jul 7 '18 at 19:33forward-sexp
in tex-mode also knows about$math$
,\(math\)
and\[math\]
. – Omar Jul 8 '18 at 0:47latex-extra
onmelpa
adds support for that kind of navigation to auctex – João Cortes Oct 20 '18 at 16:27