Skip to content

Change Surrounding Environment Error when Exclamation Point in Environment Name #2334

@ZaydH

Description

@ZaydH

Description

Change the surrounding environment command cse can change the wrong \end block when the current environment has an exclamation point in the name. Packages like optidef use an exclamation point in some environment names.

Steps to reproduce

Initial Step: nv -u minimal.vim minimal.tex

In the code LaTeX file below, I put my cursor inside the curly brackets for the line \begin{mini!}. In vim command mode, I press cse and type maxi! (or maxi does not matter).

MWE:

minimal.tex

\documentclass[10pt]{article}

\usepackage{optidef}

\begin{document}
  \begin{mini!}
    {w}{z}{}{}
    \addConstraint{X}
  \end{mini!}
\end{document}

minimal.vim (Uses vim-plug not vundle) but just loads vimtex

" =========================================================================
"     vim-plug Start
" =========================================================================

" Autoinstall vim-plug if it doesn't exist
if empty(glob('~/.vim/autoload/plug.vim'))
  silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
    \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
  autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin()

Plug 'lervag/vimtex'

" All of your Plugins must be added before the following line
call plug#end()

Expected behavior

The begin/end environment block should both change to the new environment name I specify.

Actual behavior

The begin environment block changes as expected. Instead of changing the end environment block, the \end{document} block is changed.

If the environment name does not have the ! (exclamation point), this issue is not observed.

Do you use a latexmkrc file?

Yes but not relevant since not in build mode.

VimtexInfo

System info:
  OS: Pop!_OS 21.10
  Vim version: NVIM v0.4.4
  Has clientserver: true
  Servername: /tmp/nvim8dvTvv/0
  
VimTeX project: minimal
  base: minimal.tex  
  root: /home/zayd/repos/uo_docs/notes/bpu_teaching
  tex: /home/zayd/repos/uo_docs/notes/bpu_teaching/minimal.tex
  main parser: current file verified
  document class: article
  packages: optidef
  compiler: latexmk
    engine: -pdf
    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