With auctex I can run TeX-fold-env the environment on which point currently is located.

How can I fold all environments foo (\begin{foo}... \end{foo}) in my buffer at once? And how to unfold all occurences of foo?

(defun latex-fold-foo ()
  (let ((env (read-from-minibuffer "Environment: ")))
      (goto-char (point-min))
      (while (search-forward (format "begin{%s}" env) nil t)
  • Please some explanation in addition to just code Dec 10 '18 at 16:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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