4

A latex environment looks like this:

\begin{envName}
body
\end{envName}

Is there a command to jump back-and-forth between matching \begin and \end commands? (One cannot simply use a regex search because environments can be nested)

1 Answer 1

5

LaTeX-find-matching-begin and LaTeX-find-matching-end functions do this.

   AUCTeX offers keyboard shortcuts for moving point to the beginning
and to the end of the current environment.
 -- Command: LaTeX-find-matching-begin
     ('C-M-a') Move point to the '\begin' of the current environment.
 -- Command: LaTeX-find-matching-end
     ('C-M-e') Move point to the '\end' of the current environment.
1
  • 1
    It should be noted that C-M-a and C-M-e are bound to beginning-of-defun and end-of-defun resp. in most modes and they are available in every mode, not just LaTeX-mode. They are supposed to do the "right" thing in each case: e.g. C-M-a moves to the beginning of the environment in LaTeX-mode, the beginning of a function in C mode, the beginning of a defun (doh!) in emacs-lisp-mode and so on.
    – NickD
    Commented Nov 22, 2021 at 23:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.