Skip to content

VimTeX indent does not indent comment-only lines inside environments #3203

@ChristophSchmidpeter

Description

@ChristophSchmidpeter

Description

When using VimTeX’s indent engine (VimtexIndentExpr), comment-only lines inside environments do not inherit the surrounding indentation.
Instead, they are always placed at column 0.
This makes the source look inconsistent compared to stock GetTeXIndent() behaviour, where comment-only lines follow the previous non-blank line’s indent.

Steps to reproduce

  1. Ensure VimTeX indent is enabled (vim.g.vimtex_indent_enabled = 1).
  2. Open the minimal examples for expected and actual behavior.
  3. Select the comment line via 'V' (uppercase) keypress
  4. Run formatting of selected line via '=' keypress.

Expected behavior

\documentclass{minimal}
\begin{document}
\begin{flushleft}
  % this comment IS indented like line below
  Hello world!
\end{flushleft}
\end{document}

Actual behavior

\documentclass{minimal}
\begin{document}
\begin{flushleft}
% this comment IS NOT indented like line below
  Hello world!
\end{flushleft}
\end{document}

Do you use a latexmkrc file?

No

VimtexInfo

/c

System info:
  OS: Arch Linux
  LaTeX version: pdfTeX 3.141592653-2.6-1.40.27 (TeX Live 2026/dev/Arch Linux)
  Vim version: NVIM v0.11.3
  Has clientserver: true
  Servername: /run/user/1000/nvim.682510.0
  $PATH:
    - /home/vbm/.local/bin
    - /home/vbm/.local/share/JetBrains/Toolbox/scripts
    - /home/vbm/.local/share/nvim/mason/bin
    - /home/vbm/.local/share/zinit/plugins/StackExchange---blackbox/bin
    - /home/vbm/.local/share/zinit/polaris/bin
    - /opt/android-sdk/emulator
    - /opt/android-sdk/platform-tools
    - /opt/android-sdk/tools
    - /opt/android-sdk/tools/bin
    - /usr/bin
    - /usr/bin/core_perl
    - /usr/bin/site_perl
    - /usr/bin/vendor_perl
    - /usr/lib/jvm/default/bin
    - /usr/lib/rustup/bin
    - /usr/local/bin
    - /usr/local/sbin
    - /var/lib/snapd/snap/bin

VimTeX project: minimal
  base: minimal.tex
  root: /tmp
  tex: /tmp/minimal.tex
  main parser: fallback current file
  document class: 
  document class options: 
  compiler: latexmk
    engine: -xelatex
    options:
      -verbose
      -file-line-error
      -synctex=1
      -interaction=nonstopmode
    callback: 1
    continuous: 1
    executable: latexmk
  viewer: General
  qf method: LaTeX logfile

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions