Skip to content

Disregard contents of "comment" environment #2882

Closed
@boolanger

Description

@boolanger

Issue

Vimtex currently treats \section{...}, \subsection{...}, and \subsubsection{..} commands inside the comment environment as if they were real sections in at least these ways (I may have missed others):

  • It folds them as (sub)sections.
  • It lists them in the table of contents (vimtex-toc).
  • It navigates to them with [[, ]], [], and ][ in normal mode.
  • It selects up to such commands with the aP and iP text objects.

To reproduce, open the following with vim:

\documentclass{article}
\usepackage{comment}
\begin{document}
\section{Real section}
\begin{comment}
\section{Commented section}
\subsection{Commented subsection}
\subsubsection{Commented subsubsection}
\end{comment}
\end{document}

with .vimrc

call plug#begin('~/.vim/plugged')
Plug 'lervag/vimtex'
call plug#end()
let g:vimtex_fold_enabled=1

Proposed Solution

I think that it would be better to disregard commented (sub)section commands, since they are not part of the structure of the document. That would mean:

  • They are not folded as (sub)sections.
  • They are not listed in vimtex-toc, and don't affect the (sub)section count.
  • [[, ]], [], and ][ skips over them.
  • Similarly, iP and aP skips over them.

Personally, I like the ability to comment out entire sections, and this would help me do that without messing up document navigation.

By the way, thanks for all your work on vimtex, it's much appreciated!

Edit: For clarity, and I've also added some more features that are affected by this.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions