Giordano solution works perfectly but the fold will be gone after the buffer killed. Each time you want to fold, you need to run the function again.
I have another solution to automatically fold everything you want.
I use this function with comments.
Example:
% Why I write this paragraph in latex \begin{fold}
% comment
% another comment
% \end{fold}
or You want to fold paragraph or other
% Paragraph that explains about A \begin{fold}
A is a letter. Another sentence. End of paragraph.
% \end{fold}
When nyou run this function. M-x latex-fold-foo
It will fold everythig that \begin{fold} \end{fold}
The result like this
% Why I write this paragraph in latex [fold]
% Paragraph that explains about A [fold]
Each time you move your cursor to the folded paragraph, It will open it temporarily.
If you want to remove the fold, use C-c C-o i
(defun latex-fold-foo ()
(interactive)
(save-excursion
(goto-char (point-min))
(while (search-forward (format "begin{fold}") nil t)
(TeX-fold-env))))
My workflow is
- Open the buffer
- Run the function to automatically fold everything
- C-c C-o i to delete the fold if u want to edit it and see it permanently
\newcommand
s, you may find documentation about emacs tags interesting: gnu.org/software/emacs/manual/html_node/emacs/Tags.html