2

Are there any good alternative plugins that someone has put together for working with latex in vim?

I use the vim-latex latex suite, but it's a bit much. I'm pretty sure I use maybe 10% of the features - and I don't really like some of the design choices. However, it is much better than nothing. I'd just like something more lightweight, with just a few basic macros, code highlighting, folding, compiling, etc.

  • Vimtex is nice. There is also a list of alternatives with a summary of the main differences between the packages. Also look here: https://vi.stackexchange.com/questions/2047/what-are-the-differences-between-latex-plugins – DG' Feb 13 '19 at 21:40
  • 2
    There are four different options for Vim listed in https://tex.stackexchange.com/questions/339/latex-editors-ides – Torbjørn T. Feb 13 '19 at 21:51
  • Thanks - both helpful. This answer in particular was what I was looking for: https://vi.stackexchange.com/a/5747/20985 – argentum2f Feb 14 '19 at 19:01

1 Answers1

2

An alternative is one tool for one job :

Code highlighting : just vim

In .vimrc : syntax on

Folding : just vim

In .vimrc : set fdm=marker
Commands : zc, zo, zr, zm.
I open and close a section with %{{{1 and %}}}, a subsection with %{{{2 %}}}. A long TikZ code goes in %{{{ and %}}}= so it is immune to zr or zm.

Spell checking : just vim

In ftplugin/tex.vim (filetype plugin on in .vimrc):
setlocal spell
In normal mode:
- zg (add Good word to local dict.).
- zw (remove wrong word from local dict.)

Compiling 1 : just vim8.1

:term latexmk -pdf -pv %

Compiling 2 : latexmk (in tmux using Dispatch in vim)

  1. When pressing <LocalLeader>L, latexmk compiles in the background and the pdf shows up on success. On failure, I press :Copen to view the error messages in a vim split.
  2. When pressing <LocalLeader>l, latexmk spits out its output in a vim split (actually in a tmux split during compilation) and the pdf shows up.

Here are the commands in ftplugin/tex.vim:

nnoremap <LocalLeader>l :w<CR> :Dispatch  latexmk -pdf -pv -halt-on-error %<CR>
nnoremap <LocalLeader>L :w<CR> :Dispatch! latexmk -pdf -pv -halt-on-error %<CR>

Code checking / Linting : ALE (using chktex)

In ftplugin/tex.vim (filetype plugin on in .vimrc) :

execute "packadd ale"
let b:ale_fixers = ['remove_trailing_lines',  'trim_whitespace']
let b:ale_linters = ['chktex’]

NOTE: To ignore the error type 6 at a particular line, I add that to its end % chktek 6

Grammar checking : vim-grammarous

In ftplugin/tex.vim (filetype plugin on in .vimrc):

execute "packadd vim-grammarous"
nnoremap <LocalLeader>g   :GrammarousCheck --lang=fr<CR>
vnoremap <LocalLeader>g   :'<,'>GrammarousCheck --lang=fr<CR>
nnoremap <LocalLeader>G   :GrammarousReset<CR>
  • How you have managed to use vim-grammarous with latex? it check syntaxes also, and gives error there, right from \documentclass. – BaRud Jun 23 '20 at 19:03