# What are the differences between LaTeX plugins?

There are a number of Tex plugins for vim (vim-latex, AutomaticLatexPlugin to say a couple).

What are the differences in the provided functionalities between these (the ones I named and possibly others) TeX plugins?

Here is a couple of related questions on SO:

I will not provide an in-depth comparison, as I only have limited experience with the different plugins. I know a couple of plugins well (LaTeX-Box and LaTeX-Suite), and I know one plugin very well, since I am developing it myself: vimtex. Thus, I will mostly write about vimtex. However, I will first point out some references that might be of interest to others.

# Some overview and references

There are alot of plugins for Vim. These are the ones I've recognized as being at least semi popular:

On tex.stackexchange.com, there is a huge list of LaTeX editors and IDEs. It gives a nice overview in general, but it also provides some overview of plugins for Vim:

# vimtex

vimtex is based on LaTeX-Box. It started out after I had contributed bug fixes and updates to LaTeX-Box for some time. I realized that the plugin could be written in a much more modern way if I wrote it from scratch. I first stripped most features and built a more robust and modular "engine". I then added features, and I think today it has most of the features of LaTeX-Box and then some.

Instead of giving a full list of features (see instead here for that), I will rather try to point out some of the differences between vimtex and other plugins. However, I want to provide some bold claims:

• vimtex is the most modern Vim plugin for LaTeX available today
• The code is high quality and it is currently being actively maintained by myself
• The plugin is mostly stable, even though some features are still being developed (and as such may be subject to change and updates)

## vimtex vs LaTeX-Box

Since vimtex is based on LaTeX-Box, it obviously has similar principles. The idea is to keep things simple and to solve problems thare are not already solved by other, better plugins. It utilizes latexmk to compile the LaTeX documents, and it builds upon the internal Vim plugin for syntax highlighting.

There is currently one important feature in LaTeX-Box that is missing in vimtex: Single-shot compilation with callback. The reason that this feature is not in vimtex is simply because it is complicated, and that I never found a way to implement it that is simple enough for my own preference (suggestions are welcome, please don't hesitate to open issues or pull requests).

## vimtex vs LaTeX-Suite

The main difference between vimtex and LaTeX-Suite 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 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.
• Just want to make it clear: vimtex can work side-by-side with Latex-Suite, which means you can get the best of the two plugins at the same time. :) Apr 21 '17 at 0:35
• How does vimtex compare to something like using coc together with coc-texlab? Can you use both of them together? Nov 18 '19 at 16:36
• I don't know, as I've not used texlab yet. But I think it should work well together. You could use texlab with coc.nvim or other LSP-implementations for e.g. completion, which might work better than vimtex completion. But I would say vimtex completion is quite good, and so it should not be much better. vimtex does provide a lot of other features as well, though, which would be orthogonal to the LSP. Nov 19 '19 at 17:28
• For more information, see this issue comment on the vimtex repo. Nov 19 '19 at 17:29

I can't do comparison, as Vim-LaTeX is the only LaTeX plugin I've used. I have been using Vim-LaTeX for almost a year. So I will talk about Vim-LaTeX alone.

There are many features present in Vim-LaTeX. I don't remember all of them. I'll just talk about features that I know and use constantly.

Note: These are my limited user experience, which may be very misleading. I'm not a seasoned Vim user. And I know of nothing about vimscript.

# IMAP() and <C-j> Jumpping

IMAP() function and <C-j> jumpping functions are provided separately as a plugin imaps.vim in Vim-LaTeX bundle. They are powerful features and could be very useful even when you are not writing LaTeX.

• IMAP() function provides a more natural way to do insert mode mappings and templating in general than the built-in imap and iabbrev, IMO.

• <C-j> jumpping is utilized by many Vim-LaTeX completion features. A jumpping point is indicated by <++>.

• Built-in insert mode key mappings are implemented as IMAP() calls. For example, you can find a long list of useful IMAP() calls in main.vim file:

call IMAP ('__', '_{<++>}<++>', "tex")
call IMAP ('()', '(<++>)<++>', "tex")
call IMAP ('[]', '[<++>]<++>', "tex")
call IMAP ('{}', '{<++>}<++>', "tex")
...
call IMAP ('((', '\left( <++> \right)<++>', "tex")
call IMAP ('[[', '\left[ <++> \right]<++>', "tex")
call IMAP ('{{', '\left\{ <++> \right\}<++>', "tex")
...


Then when you type say (), the cursor will reside automatically between the parenthese, replacing the first <++>. After you finished typing inside, you kick <C-j> and bang, the cursor will move out of parenthese and you just keep typing forward. Once you are used to it, it begins to form a typing flow which is kinda addictive...

You see from above a \left \right pair can be typed easily with double stroke of its opening bracket. And <C-j> jumpping makes typing flow.

One major glitch of IMAP() and <C-j> thing is that they messes up your last change history. (One bug I wish to fix for a long time.) Therefore, you may encounter unexpected behavior when trying to redo your last change by . if your "supposed last change" contains these function calls.

• You can do all kinds of mappings using IMAP(), from simple key mappings to more complex templating. Here are some examples of my mappings (ftplugin/tex.vim):

call IMAP('*EEQ',"\\begin{equation*}\<CR><++>\<CR>\\end{equation*}<++>",'tex')
call IMAP('DEF',"\\begin{definition}[<++>]\<CR><++>\<CR>\\end{definition}<++>",'tex')
call IMAP('BIC','\binom{<++>}{<++>}<++>','tex')
call IMAP('PVERB','\PVerb{<++>}<++>','tex')
call IMAP('VERB','\verb|<++>|<++>','tex')

• An interesting fact about imaps.vim plugin is that it's a global plugin, which implies its potential usage beyond LaTeX. Indeed, I do use <++> and <C-j> jumppings (combining with other plugins) to build code snippet templates in C.

# <F5> <F7> Insertion of Commands and Environments

One disadvantage of IMAP() is that the key combination can not be used in normal text anymore (unless you undo the mapping by u). In the cases that you just want to trigger the mapping as you wish, the <F5> and <F7> come in handy. These two keys are used for triggering environments and inline commands insertion, respectively. And they behave differently based on the mode and customizations from user.

• In Insert/Normal Mode, when the cursor is attaching a word or is in the word, pressing <F5> will by default insert a basic environment of the form

\begin{word}
<Cursor>
\end{word}<++>


based on the word; pressing <F7> will by default insert a basic inline command of the form \word{}<++> based on the word.

• "By default", I mean you can customize the behavior of a specific word when triggered by <F5>/<F7>. Here are some of my settings (.vimrc):

let g:Tex_Com_latex = "{\\LaTeX}<++>"
let g:Tex_Com_D = "\\D{<++>}{<++>}<++>"

• In Insert/Normal Mode, when the cursor is not attached to anything (a.k.a alone), pressing <F5>/<F7> will prompt to you a menu to select environment/command to insert. Or you can type the name of desired environment/command at the bottom. Personally, I rarely use <F5>/<F7> this way.

• Press <F5>/<F7> after visually selecting a piece of text will prompt a menu for wrapping text. Then the selected text will be wrapped in the environment/command you selected or typed.

• In Insert/Normal Mode, when the cursor is in the scope of an environment/command, press <Shift>+<F5>/<F7> will prompt a menu for changing environment/command.

# Misc Key Mappings

• Greek Letters. a to z and corresponding capitals.
• Symbols like 8 for \infty, < for \le, I for \int_{<++>}^{<++>}<++>, etc.
• Pressing " twice gets a pair of TeX double quotes. So to type literal " character, you have to use .
• Pressing in several enumeration environments will insert appropriate \item tag.
• You can wrap visually selected part of math in \left \right pair by (, [ and {.
• Folding is customizable. Three global variable control what can be folded: Tex_FoldedSections, Tex_FoldedMisc, and Tex_FoldedEnvironments.

Sometimes the built-in mappings have just gone too far or are not quit what you want. You can override the built-in mappings by redefining them in after/ftplugin/tex.vim:

call IMAP('|','\abs{<++>}<++>','tex')
call IMAP('ETE',"\\begin{table}\<CR>\\centering\<CR>\\caption{<+Caption text+>}\<CR>\\label{tab:<+label+>}\<CR>\\begin{tabular}{<+dimensions+>}\<CR><++>\<CR>\\end{tabular}\<CR>\\end{table}<++>",'tex')
call IMAP('==','==','tex')
call IMAP('\','\','tex')


# Set Multiple Compilation Engine

I always need to switch between pdflatex and xelatex engine. Thus, I have the following lines in my .vimrc:

"switch to pdflatex
function SetpdfLaTeX()
let g:Tex_CompileRule_pdf = 'pdflatex --interaction=nonstopmode -synctex=1 -src-specials $*' endfunction noremap <Leader>lp :<C-U>call SetpdfLaTeX()<CR> "switch to xelatex function SetXeLaTeX() let g:Tex_CompileRule_pdf = 'xelatex --interaction=nonstopmode -synctex=1 -src-specials$*'
endfunction
`

# View PDF, Forward and Backward Search between Vim and PDF viewer

This is a messy and complicated topic. With certain PDF viewer and a certain amount of luck, it can be very easy. But it's mainly a matter of google search.

# Suggestions

• You should find your balance between LaTeX way and Vim-LaTeX way.
• Vim-LaTeX is no light-weight at all. There are some features and/or key mappings you'll possibly never gonna use and you have to manually override them.
• You use Vim. You know what patience mean. :-)

Overall, I think it will work well if you are willing to invest some time to tame the beast. That being said, had I time and adequate knowledge, I will surely thin off the overhead features and explore the potentials of integration with other plugins.