VimTeX autoload mechanism
masterautoload concept to improve startup performance. The bulk of the plugin's code is not sourced until it is strictly necessary, preventing slow initialization of the editor.repository·master·Indexed 27 days ago
https://github.com/lervag/vimtexA modern LaTeX filetype and syntax plugin for Vim (v9.2+) and Neovim (v0.12.4+). It provides advanced features for LaTeX editing, including compilation support for latexmk, latexrun, tectonic, and arara; PDF viewing with forward search; specialized motions and text objects; and a comprehensive completion API. The plugin includes built-in support for syntax highlighting, indentation, and project management for import and subfiles packages.
autoload concept to improve startup performance. The bulk of the plugin's code is not sourced until it is strictly necessary, preventing slow initialization of the editor.VimTeX provides a comprehensive suite of features for LaTeX editing, accessible via commands and mappings (defaulting to <localleader>l).
Key capabilities include:
latexmk, latexrun, tectonic, or arara.pplatex.gf command.texcount.import and subfiles packages.tex and bib filetypes. The main entry points for its functionalities are located in the ftplugin/ directory. When a LaTeX or BibTeX file is opened, these scripts ensure VimTeX is loaded and then execute vimtex#init() from autoload/vimtex.vim.Use the following commands to delete LaTeX structural elements while preserving their contents:
dsc deletes a LaTeX command but preserves its arguments and square-bracket parameters.dse deletes the \begin{} and \end{} declarations of an environment without changing its contents.ds$ deletes surrounding math zones (display math, standard environments, or inline math) without changing the math contents.dsd deletes delimiters (e.g., (), [], {} and \left\right / \big variants) without changing the enclosed content.Quickly switch between different LaTeX states using toggle commands:
tsc to toggle starred commands and tss to toggle starred environments (Note: tss was renamed from tse in v2.16).tse to toggle between related environments (e.g., itemize $\leftrightarrow$ enumerate).ts$ to toggle between inline math, display math, and standard math environments.tsd to toggle between plain delimiters and their \left/\right versions. You can extend this list using the g:vimtex_delim_toggle_mod_list variable.tsf to toggle between inline fractions and \frac{}{} versions.Use VimTeX motion commands to jump through the document structure:
]] to jump to the next \section, \subsection, or \subsubsection. Use [[ to jump backward. For more granular control, see :help <Plug>(vimtex-][) and :help <Plug>(vimtex-[]).]m to jump to the next \begin{} environment and [m for the previous one. Use ]M and [M for alternative navigation (see :help <Plug>(vimtex-]M) and :help <Plug>(vimtex-[M)).]n to jump to the next math zone and [n for the previous one. Use ]N and [N for alternative navigation (see :help <Plug>(vimtex-]N) and :help <Plug>(vimtex-[N)).]r to jump to the next Beamer frame and [r for the previous one. Use ]R and [R for alternative navigation (see :help <Plug>(vimtex-]R) and :help <Plug>(vimtex-[R)).% to jump between matching delimiters, inline-math $ delimiters, and LaTeX environments.Add one of the following lines to your .vimrc or init.vim to install VimTeX using vim-plug. You can either use the latest version from the master branch or pin to a specific release tag.
Plug 'lervag/vimtex'
Plug 'lervag/vimtex', { 'tag': 'v2.15' }To install VimTeX using lazy.nvim in Neovim, add the following plugin spec.
CRITICAL: Do not use lazy loading for VimTeX. While VimTeX is already lazy-loaded via filetype plugins and autoload mechanisms, forcing lazy loading through your plugin manager will break the inverse-search mechanism (which requires the global command :VimtexInverseSearch). Set lazy = false to ensure correct functionality.
{
"lervag/vimtex",
lazy = false, -- we don't want to lazy load VimTeX
-- tag = "v2.15", -- uncomment to pin to a specific release
init = function()
-- VimTeX configuration goes here, e.g.
vim.g.vimtex_view_method = "zathura"
end
}The VimTeX documentation website is a web-published version of the VimTeX help (doc/vimtex.txt). You can build and host the site locally using mise commands.
mise run web-host to host the site.mise run web-build to rebuild the pages.# to host the site
mise run web-host
# to rebuild the page
mise run web-buildVimTeX extends Vim's movement capabilities specifically for LaTeX structures.
[[, [], ][, ]] move between section boundaries.[m, [M, ]m, ]M move between environment boundaries.[n, [N, ]n, ]N move between math environment boundaries.[r, [R, ]r, ]R move between frame environment boundaries.[* and ]* move between comment boundaries.% moves between matching delimiters.ic (inner command), ac (around command).id (inner delimiter), ad (around delimiter).ie (inner environment), ae (around environment).i$ (inner math), a$ (around math).iP (inner section), aP (around section).im (inner item), am (around item).VimTeX requires specific versions of Vim or Neovim:
If you are using older versions, do not use the latest VimTeX release; instead, pin your installation to the v2.17 tag or older.
Certain features require external tools. For example, the default compiler backend relies on latexmk. For a full list of requirements, refer to :help vimtex-requirements in Vim/Neovim.
Use the following commands to modify the type of LaTeX element surrounding your cursor without changing the content itself:
csc changes a LaTeX command while preserving its arguments.cse changes the type of a LaTeX environment (e.g., switching from itemize to enumerate).cs$ changes the type of math zone (e.g., switching between inline math, display math, and standard math environments).csd changes delimiters (e.g., switching between () and []) and is smart enough to preserve \left\right or \big modifiers.