Skip to content

Using TeX files in Vi🔗

In Vim/Neovim the filetype plugin uses three different type for different TeX flavors (see :help ft-tex-plugin).

  • TeX: plaintex
  • LaTeX: tex
  • ConTeXt: context

Which filetype the current buffer was assigned, can be shown with :set filetype? (or :LspInfo if LSP is enabled).

All files with the extension *.tex are of type plaintex. When the file type plugin finds specific keywords the file type is than changed to tex or context.

The automatic guessing can be disabled with the following two mechanisms.

Add the TeX flavor in the first line of a *.tex file:

%&latex

Or set the global variable tex_flavor:

let g:tex_flavour = "latex"
vim.g.tex_flavor = 'latex'

See :help lua-guide-variables for more information about the Lua wrappers for different variable scopes.