VimTeX requires Vim version 8.0.1453 or Neovim version 0.4.3. The requirements
were updated in July 2020 after the release of VimTeX 1.0. If you are stuck
on older versions of Vim or Neovim, then you should not use the most recent
version of VimTeX, but instead remain at the v1.0 tag.
Some features require external tools. For example, the default compiler backend
relies on latexmk.
Users are encouraged to read the requirements section in the
documentation (:h vimtex-requirements).
Installation
If you use vim-plug or packer.nvim, then add one of the
following lines to your vimrc file, correspondingly:
" vim-plug
Plug 'lervag/vimtex'" packer.nvim
use 'lervag/vimtex'
If you use the new package feature in Vim, please note the following:
Make sure to read and understand the package feature: :help package!
Use the /pack/foo/start subdirectory to make sure the filetype plugin is
automatically loaded for the tex filetypes.
Helptags are not generated automatically. Run :helptags to generate them.
Please note that by default Vim puts custom /start/ plugin directories at
the end of the &runtimepath. This means the built in filetype plugin is
loaded, which prevents VimTeX from loading. See
#1413 for two suggested
solutions to this. To see which scripts are loaded and in which order, use
:scriptnames.
For more information on how to use the Vim native package solution, see
here
and here.
Configuration
After installing VimTeX, you should edit your .vimrc file or init.vim file
to configure VimTeX to your liking. Users should read the documentation to
learn the various configuration possibilities, but the below is a simple
overview of some of the main aspects.
" This is necessary for VimTeX to load properly. The "indent" is optional." Note that most plugin managers will do this automatically.filetypepluginindenton" This enables Vim's and neovim's syntax-related features. Without this, some" VimTeX features will not work (see ":help vimtex-requirements" for more" info).syntaxenable" Viewer options: One may configure the viewer either by specifying a built-in" viewer method:letg:vimtex_view_method='zathura'" Or with a generic interface:letg:vimtex_view_general_viewer='okular'letg:vimtex_view_general_options='--unique file:@pdf\#src:@line@tex'" VimTeX uses latexmk as the default compiler backend. If you use it, which is" strongly recommended, you probably don't need to configure anything. If you" want another compiler backend, you can change it as follows. The list of" supported backends and further explanation is provided in the documentation," see ":help vimtex-compiler".letg:vimtex_compiler_method='latexrun'" Most VimTeX mappings rely on localleader and this can be changed with the" following line. The default is usually fine and is the symbol "\".let maplocalleader =","
Note: If the compiler or the viewer doesn't start properly, one may
type <localleader>li to view the system commands that were executed to
start them. To inspect the compiler output, use <localleader>lo.
Quick Start
The following video shows how to use VimTeX's main features (credits:
@DustyTopology from
#1946).
The example LaTeX file used in the video is available under
test/example-quick-start/main.tex and it
may be instructive to copy the file and play with it to learn some of these
basic functions.
Screencast.mp4
Both new and experienced users are also encouraged to read the third-party
article Getting started with the VimTeX
plugin. The
article covers VimTeX's core features and contains plenty of examples and
high-resolution animations intended to help new users ease into working with
the plugin.
Users are of course strongly encouraged to read the documentation, at least
the introduction, to learn about the different features and possibilities
provided by VimTeX (see :h vimtex). Advanced users and
potential developers may also be interested in reading the supplementary
documents:
Here is an example of the syntax highlighting provided by VimTeX. The conceal
feature is active on the right-hand side split. The example is made by
@DustyTopology with the
vim-colors-xcode colorscheme with
some minor adjustments described
here.
Additionally, you can find animated demonstrations of VimTeX's core motions,
text-editing commands, and text objects in the file VISUALS.md.
Features
Below is a list of features offered by VimTeX. The features are accessible as
both commands and mappings. The mappings generally start with <localleader>l,
but if desired one can disable default mappings to define custom mappings.
Nearly all features are enabled by default, but each feature may be disabled if
desired. The two exceptions are code folding and formating, which are disabled
by default and must be manually enabled.
For orientation, you can watch concise demonstrations of many of the motions,
text objects, and text-editing features provided by VimTeX in the file
VISUALS.md.
See the documentation for a thorough introduction to VimTeX (e.g. :h vimtex).
Other relevant plugins
Even though VimTeX provides a lot of nice features for working with LaTeX
documents, there are several features that are better served by other,
dedicated plugins. For a more detailed listing of these, please see :help vimtex-and-friends.
The main difference between VimTeX and LaTeX-Suite (aka vim-latex) is
probably that VimTeX does not try to implement a full fledged IDE for LaTeX
inside Vim. E.g.:
VimTeX does not provide a full snippet feature, because this is better
handled by UltiSnips or
neosnippet or similar snippet
engines.
VimTeX builds upon Vim principles: It provides text objects for
environments, inline math, it provides motions for sections and
paragraphs
VimTeX uses latexmk, latexrun, tectonic or arara for compilation
with a callback feature to get instant feedback on compilation errors
VimTeX is very modular: if you don't like a feature, you can turn it off.
"A simple, lightweight Neovim plugin that facilitates LaTeX build engine
selection via magic comments. It is designed with the TexLab LSP server's
build functionality in mind, which at the time of this plugin's inception
had to be specified in init.lua/init.vim and could not be set on
a by-project basis."
This plugin should be combined with the TexLab LSP server, and it only
works on neovim.
VimTeX currently has most of the features of LaTeX-Box, as well as
some additional ones. See here for a relatively complete list
of features.
One particular feature that LaTeX-Box has but VimTeX misses, is the ability
to do single-shot compilation with callback. This functionality was
removed because it adds a lot of complexity for relatively little gain
(IMHO).
VimTeX users may be interested in reading
@ejmastnak's series on Efficient LaTeX Using
(Neo)Vim, which
covers all the fundamentals of setting up a VimTeX-based LaTeX workflow,
including usage of the VimTeX plugin, compilation, setting up forward and
inverse search with a PDF reader, and Vimscript tools for user-specific
customization.
If you know of (or create) other up-to-date, high-quality guides to VimTeX's
features on third-party websites, feel free to submit a pull request updating
this section.
请发表评论