-
Notifications
You must be signed in to change notification settings - Fork 394
/
Copy pathvimtex.txt
3462 lines (2758 loc) · 143 KB
/
vimtex.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
*vimtex.txt* A modern vim plugin for editing LaTeX files.
*vimtex*
Author: Karl Yngve Lervåg <[email protected]>
License: MIT license {{{
Copyright (c) 2018 Karl Yngve Lervåg
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
}}}
==============================================================================
CONTENTS *vimtex-contents*
Introduction |vimtex-introduction|
Feature overview |vimtex-features|
Features provided by other plugins |vimtex-non-features|
Requirements |vimtex-requirements|
Support for multi-file projects |vimtex-multi-file|
Comment on internal tex plugin |vimtex-comment-internal|
Support for TeX specifiers |vimtex-tex-directives|
Package detection |vimtex-package-detection|
Usage |vimtex-usage|
Default mappings |vimtex-default-mappings|
Options |vimtex-options|
Commands |vimtex-commands|
Map definitions |vimtex-mappings|
Insert mode mappings |vimtex-imaps|
Events |vimtex-events|
Completion |vimtex-completion|
Complete citations |vimtex-complete-cites|
Complete labels |vimtex-complete-labels|
Complete commands and environments |vimtex-complete-commands|
|vimtex-complete-environments|
Complete image file names |vimtex-complete-images|
Complete input file names |vimtex-complete-input|
Complete PDF file names |vimtex-complete-pdf|
Complete standalone file names |vimtex-complete-standalone|
Complete glossary entries |vimtex-complete-glossary|
Complete packages and documentclasses |vimtex-complete-packages|
|vimtex-complete-classes|
Autocomplete |vimtex-complete-auto|
Neocomplete |vimtex-complete-neocomplete|
deoplete |vimtex-complete-deoplete|
nvim-completion-manager |vimtex-complete-ncm|
YouCompleteMe |vimtex-complete-youcompleteme|
VimCompletesMe |vimtex-complete-vcm|
Folding |vimtex-folding|
Indentation |vimtex-indent|
Syntax highlighting |vimtex-syntax|
Navigation |vimtex-navigation|
Table of contents |vimtex-toc|
Table of labels |vimtex-labels|
Unite sources |vimtex-unite|
Include expression (|gf| command) |vimtex-includeexpr|
Compilation |vimtex-compiler|
Latexmk |vimtex-latexmk|
Latexrun |vimtex-latexrun|
Arara |vimtex-arara|
View |vimtex-view|
Synctex |vimtex-synctex|
Forward search |vimtex-synctex-forward-search|
Backward search |vimtex-synctex-backward-search|
LaTeX Documentation |vimtex-latexdoc|
Code structure |vimtex-code|
FAQ |vimtex-faq|
Troubleshooting |vimtex-troubleshooting|
Credits |vimtex-credits|
Changelog |vimtex-changelog|
==============================================================================
INTRODUCTION *vimtex-introduction*
|vimtex| provides convenient functionality for editing LaTeX documents. The
main goal of |vimtex| is to be simple, functional, and to be easy to customize
and evolve.
-----------------------------------------------------------------------------
Feature overview~
*vimtex-features*
- Document compilation with `latexmk`, `latexrun`, or `arara`
- LaTeX log parsing for quickfix entries using
- internal method
- `pplatex`
- Compilation of selected part of document
- Support for several PDF viewers with forward search
- `MuPDF`
- `Zathura`
- `Okular`
- `qpdfview`
- `SumatraPDF`
- Other viewers are supported through a general interface
- Completion of
- citations
- labels
- commands
- file names for figures, input/include, includepdf, includestandalone
- glossary entries
- package and documentclass names based on available `.sty` and `.cls` files
- Document navigation through
- table of content
- table of labels
- enhanced `gf` command
- Easy access to (online) documentation of packages
- Word count (through `texcount`)
- Motions
- Move between sections with `[[`, `[]`, `][`, `]]`
- Move between matching delimiters with `%`
- Text objects
- `ic` `ac` Commands
- `id` `ad` Delimiters
- `ie` `ae` LaTeX environments
- `i$` `a$` Inline math structures
- `iP` `aP` Sections
- Other mappings
- Delete the surrounding command, environment or delimiter with
`dsc`/`dse`/`ds$`/`dsd`
- Change the surrounding command, environment or delimiter with
`csc`/`cse`/`cs$`/`csd`
- Toggle starred command or environment with `tsc`/`tse`
- Toggle between e.g. `()` and `\left(\right)` with `tsd`/`tsD`
- Close the current environment/delimiter in insert mode with `]]`
- Insert new command with `<F7>`
- Convenient insert mode mappings for faster typing of e.g. maths
- Folding
- Indentation
- Improved syntax highlighting
- Highlight matching delimiters
- Support for `biblatex`/`natbib` package
- Support for `cleveref` package
- Support for `listings` package
- Nested syntax highlighting (`minted`, `dot2tex`, `lualatex`,
`gnuplottex`, `asymptote`)
- Support for multi-file project packages
- `import`
- `subfiles`
------------------------------------------------------------------------------
Features provided by other plugins~
*vimtex-non-features*
The following is a short list of features that one might think should be
provided by vimtex, but that are instead provided by other plugins.
Linting and syntax checking~
The following is a list of good plugins that have support for (La)TeX
syntax checking.
`ale` https://github.com/w0rp/ale
`neomake` https://github.com/neomake/neomake
`syntastic` https://github.com/vim-syntastic/syntastic
All of the above plugins support `lacheck` [0], `chktex` [1], `proselint` [2].
`neomake` also supports `rubberinfo` [3].
[0]: https://www.ctan.org/pkg/lacheck
[1]: http://www.nongnu.org/chktex/
[2]: http://proselint.com/
[3]: https://www.systutorials.com/docs/linux/man/1-rubber-info/
Snippets/Templates~
Snippets and/or templates are provided by for instance `neosnippet` and
`UltiSnips`. See |vimtex-neosnippet| and |vimtex-UltiSnips| for more info.
Syntax highlighting~
See |vimtex-comment-internal|.
Tag navigation~
One may navigate by tags with the |CTRL-]| mapping, e.g. from
`\eqref{eq:example}` to the corresponding `\label{eq:example}`. However,
this requires that a tag file has been generated with |ctags|. I recommend
that one uses the maintained version of ctags [0]. In addition,
I recommend that one uses a plugin that automatically generates the tag
files as necessary, e.g. |gutentags| [1].
Note: In order to support `bibtex`, one may add the following to one's
`~/.ctags` file: >
--langdef=bib
--langmap=bib:.bib
--regex-bib=/^@[A-Za-z]+\{([^,]*)/\1/b,bib/
<
[0]: https://ctags.io/
[1]: https://github.com/ludovicchabant/vim-gutentags
Manipulate surrounding commands/delimiters/environments~
|vimtex| provides mappings that change, delete and toggle commands,
delimiters and environments (see the `ds`, `cs` and `ts` family of
mappings listed under |vimtex-default-mappings|). These mappings are
inspired by the great `vim-surround` [0] (|surround.txt|) by Tim Pope,
which provides mappings to manipulate surrounding delimiters such as `''`,
`""`, `()`, `[]`, `{}`, and `<>`. As such, the mappings from vimtex
should work well together with, and as an extension of, `vim-surround`.
Consider also the customization described under |vimtex-faq-surround|.
The mappings may be repeated with the dot mapping |.| if one has
`vim-repeat` [1].
A different possibility is to use `vim-sandwich` [2] (|sandwich.txt|) by
Machakann, which may be considered a generalisation of `vim-surround` in
that it can handle much more complex sets of delimiters. `vim-sandwich`
is relatively easy to expand with custom surroundings and has built in
support for LaTeX-specific surroundings such as quotations, ```text''`,
and math delimiters, `$\left(a+b\right)$`. For a list of supported
delimiters, see |sandwich-filetype-recipes|. `vim-sandwich` also supports
`vim-repeat` in addition to `visualrepeat.vim` [3].
Note: The default mappings of `vim-sandwich` differ from those of
`vim-surround`, in that the use `s` as the prefix. E.g., to add
surroundings, one uses `sa{motion/textobject}{type-of-surrounding}`
instead of `ys{motion/textobject}{type-of-surrounding}`. If one prefers
the map variants from `vim-surround`, these are also available as an
option, see |sandwich-miscellaneous|. And it is also easy to define
custom mappings, if one prefers that.
Note: `vim-sandwich` actually consists of three plugins that work
together. One should make sure to read the docs for all of them:
|sandwich.txt|, |operator-sandwich.txt|, and |textobj-sandwich.txt|.
[0]: https://github.com/tpope/vim-surround
[1]: https://github.com/tpope/vim-repeat
[2]: https://github.com/machakann/vim-sandwich
[3]: http://www.vim.org/scripts/script.php?script_id=3848
Enhanced matching and higlighting of delimiters~
|vimtex| highlights and allows navigation between matching pairs of
delimiters including those in math mode, such as `\bigl(` and `\bigr)`, and
the `\begin` and `\end` tags of environments. However, it does not allow
matching of middle delimiters or `\item`s.
Alternatively, one may use the plugin |match-up| [0], which offers enhanced
|matchparen| highlighting and `matchit.zip` style motions and |text-objects|
for a variety of file types. For LaTeX douments, it:
- Extends highlighting and the `%` motion to a number of middle
delimiters including,
- `\bigm` and `\middle` marked delimiters
- `\item`s in `itemize` and `enumerate` environments
- `\toprule`, `\midrule`, `\bottomrule` in the `tabular` environment.
- `\if`, `\else` and `\endif`
- Adds motions, `g%`, `[%`, and `]%` and text objects, `a%` and `i%` which move
between matching delimiters and operate on delimited text.
For example, with match-up enabled, >
\left( \frac{a}{b} \middle| q \right)
<
the motion `%` will cycle through `\left(`, `\middle|`, and `\right)`, whereas
with vimtex only `\left(` and `\right)` will be matched. The motion `g%`
will do the same, except in reverse.
To enable the plugin match-up after installation, add the following to
your vimrc: >
let g:matchup_override_vimtex = 1
<
Matching may become computationally intensive for complex LaTeX documents.
If you experience slowdowns while moving the cursor, the following option
is recommended to delay highlighting slightly while navigating: >
let g:matchup_matchparen_deferred = 1
<
Note: The exact set of delimiters recognized may differ between match-up
and vimtex. For example, the mappings `da%` and `dad` will not in general
be identical, particularly if you have customized vimtex's delimiters.
[0]: https://github.com/andymass/vim-matchup
------------------------------------------------------------------------------
Requirements~
*vimtex-requirements*
The following is a list of specific requirements for running |vimtex| and some
of its key features. There are a couple of relevant FAQs for those who use
|neovim| and those restricted to a Windows OS, see |vimtex-faq-neovim| and
|vimtex-faq-windows|.
*vimtex_version_check*
|vimtex| supports Vim version 7.4.52 and neovim version 0.1.7. It will not
load for older versions, unless one adds >
let g:vimtex_version_check = 0
<
to one's `vimrc` file. This might work, but issues due to older versions
than the mentioned here will be ignored.
`latexmk` http://users.phys.psu.edu/~collins/software/latexmk-jcc
`latexrun` https://github.com/aclements/latexrun
`arara` https://github.com/cereda/arara
|vimtex| uses `latexmk`, `latexrun`, or `arara` to compile the LaTeX document.
`latexmk` is "a perl script for running LaTeX the correct number of
times to resolve cross references, etc; it also runs auxiliary programs
(bibtex, makeindex if necessary, and dvips and/or a previewer as
requested). It has a number of other useful capabilities, for example to
start a previewer and then run latex whenever the source files are
updated, so that the previewer gives an up-to-date view of the document.
The script runs on both UNIX and MS-WINDOWS (XP, etc)." [Copied from the
latexmk page.] For more info, see |vimtex-latexmk|.
`latexrun` is similar to `latexmk` in that it runs the desired LaTeX
engine an appropriate number of times, including `bibtex`/`biber`.
However, it differs in philosophy in that it only does the build part. It
does not support continuous builds, nor automatic starting of the viewer.
However, it does parse the output log in order to provide a more concise
list of relevant warnings and error messages (this has currently not been
adapted to vimtex, as of yet).
`arara` is a TeX automation tool similar to the above mentioned tools,
but where the compilation behaviour is typically defined in the preamble
of the document.
|clientserver|
|vimtex| requires the |clientserver| for the callback functionality to
work. The callbacks are used to provide feedback when compilation is
finished, as well as to parse the log for errors and warnings and to open
the |quickfix| window when necessary.
If you use Vim under a terminal in Linux or OSX, then Vim must be
started as a command server with the command line option `--servername`,
e.g. `vim --servername VIM`. The simplest way to ensure this is to add an
alias to your `.bashrc` (or similar), that is, add: >
alias vim='vim --servername VIM'
<
This should work in most cases. For other methods of ensuring that Vim is
started with a servername, see:
http://vim.wikia.com/wiki/Enable_servername_capability_in_vim/xterm
------------------------------------------------------------------------------
Support for multi-file projects~
*vimtex-multi-file*
|vimtex| supports most multi-file documents. The main method uses a recursive
search algorithm that should find the main LaTeX file in most cases. For
special cases, there are several alternative methods for specifying the main
file. These alternative methods all require some explicit declaration of the
main file. Thus, these methods will be tried first, and the recursive search
is tried last if there are no explicit declarations that yield an appropriate
main LaTeX file candidate.
The methods are tried in the following order:
1. Buffer variable
2. TeX root directive
3. Subfiles package
4. File `.latexmain` specifier
5. Recursive search
*b:vimtex_main*
Buffer variable~
The main file may be specified through the buffer variable `b:vimtex_main`.
If one uses project specific |vimrc| files, one may then use an |autocmd| to
specify the main file through this buffer variable with >
autocmd BufReadPre *.tex let b:vimtex_main = 'main.tex'
<
*vimtex-tex-root*
TeX root directive~
It is also possible to specify the main TeX file with a comment in one of
the first five lines of the current file similar to this: >
%! TEX root = /path/to/my-main.tex
<
*vimtex-subfiles*
*vimtex-import*
Subfiles package~
|vimtex| also supports the `import` and the `subfiles` packages that can be used to
make it easier to work with multi-file projects. If one uses the `subfiles`
package, the |VimtexToggleMain| command is particularly useful.
- https://www.ctan.org/pkg/import
- https://www.ctan.org/pkg/subfiles
File .latexmain specifier~
In some cases, it might be preferable to specify the main file by creating
an indicator file. The indicator file should be an empty file, and the name
must be the name of the desired main file with `.latexmain` appended. An
example should make this clear: >
path/file.tex
path/file.tex.latexmain
path/sections/file1.tex
path/sections/file2.tex
<
Here `path/file.tex.latexmain` indicates for `file1.tex` and `file2.tex`
that `path/file.tex` is the main LaTeX file.
Recursive search~
If no other method provides an appropriate candidate, then the recursive
search detects the main LaTeX file by searching for a file in the current
and parent directories that includes the present file and has the
`\documentclass` line.
This should work in most cases, but it may fail if for instance the project
structure is something like this: >
path1/main.tex
path2/chapter.tex
<
That is, the main file detection will not work for the file `chapter.tex`,
because the main file does not live in the same folder or a parent folder.
In this particular case, the TeX root directive should work.
Note: In rare cases, such as if there are _very_ many tex files in the
directory tree, this method may be slow. One may therefore disable it
through the option |g:vimtex_disable_recursive_main_file_detection|.
------------------------------------------------------------------------------
Comment on internal tex plugin~
*vimtex-comment-internal*
Vim ships with some LaTeX support out of the box. In particular, it provides
good syntax highlighting (|ft-tex-syntax|), indentation (see the source file
$VIMRUNTIME/indent/tex.vim for the documentation), and some sensible options
(|ft-tex-plugin|).
When |vimtex| is active, it will be used as the main |ftplugin|. It will
define the same set of sensible settings as the internal plugin. However,
|vimtex| does not provide its own syntax, instead it adds a few minor
improvements to |ft-tex-syntax|, see |vimtex-syntax|. |vimtex| also provides its
own indentation plugin, see |vimtex-indent|.
Vim will generally autodetect filetypes automatically. In most cases this
works as expected, however, in some cases it will detect a file with the `tex`
suffix as a |plaintex|. To prevent this, one may set the option
|g:tex_flavor| in ones `vimrc` file, that is: >
let g:tex_flavor = 'latex'
------------------------------------------------------------------------------
Support for TeX directives~
*vimtex-tex-directives*
|vimtex| supports two of the commonly used TeX directives [0]: the TeX root and
the TeX program directive. The TeX root directive was already described above,
see |vimtex-tex-root|.
*vimtex-tex-program*
The TeX program directive works by specifying the TeX compiler program in
a comment in one of the first lines of the main project file. It is parsed
during initialization, but if desired one may manually reload vimtex in order
to reset the program during an editing session. See |VimtexReload| and
|<plug>(vimtex-reload)| (by default mapped to `<localleader>lx`).
The syntax is best explained with an example: >
%! TEX program = program
Here `program` may be one of the following: >
pdflatex [default]
lualatex
xelatex
context (pdftex)
context (luatex)
context (xetex)
See also [0,1].
[0]: https://tex.stackexchange.com/q/78101/34697
[1]: https://github.com/lervag/vimtex/issues/713
------------------------------------------------------------------------------
Package detection~
*vimtex-package-detection*
vimtex maintains a list of latex packages that are required by the current
project. This list is used by vimtex for instance to determine which commands
to suggest during command completion (see |vimtex-complete-commands|) and
which packages to look up documentation for (see |vimtex-doc-package|). The
list can be viewed with |:VimtexInfo|.
The package list is determined in two ways: >
1. If a `.fls` file exists having the name of the main file, it is scanned.
This file is created by the tex program (e.g., pdflatex) during compilation
and might not be supported by all tex programs. Parsing the `.fls` file is
done both at vimtex initialization and after each successful compilation,
if possible.
Note: Parsing after successful compilations requires that one uses
a) continuous compilation with callbacks (see the `callback` option
for |g:vimtex_compiler_latexmk|), or
b) single-shot compilation with the `jobs` or `nvim` backend (see the
`backend` option of |g:vimtex_compiler_latexmk| and
|g:vimtex_compiler_latexrun|). If one uses the `process` backend
(e.g. on older Vim versions), one must either have the `callback`
option also enabled or it must run in foreground.
2. Otherwise, the preamble is parsed for `\usepackage` statements. This is
slower and less accurate than `.fls` file parsing. Therefore, it is only
done during vimtex initialization. If desired, one may manually reload
vimtex to parse the preamble again during an editing session. See
|VimtexReload| and |<plug>(vimtex-reload)| (by default mapped to
`<localleader>lx`).
==============================================================================
USAGE *vimtex-usage*
Default mappings |vimtex-default-mappings|
Options |vimtex-options|
Commands |vimtex-commands|
Map definitions |vimtex-mappings|
Insert mode mappings |vimtex-imaps|
Events |vimtex-events|
------------------------------------------------------------------------------
Default mappings~
*vimtex-default-mappings*
|vimtex| is designed to be controlled by a selection of mappings. Note,
though, that most of the mappings are also available as commands, see
|vimtex-commands|.
Many of the mappings utilize the |maplocalleader|. The right-hand sides are
provided as <plug>-mappings, see |using-<plug>|. For any given <plug> map, the
default mapping will only be created if it does not already exist. This means
that if a user defines a custom mapping, e.g. with >
nmap <space>li <plug>(vimtex-info)
then the corresponding default left-hand side will not be mapped.
If one prefers, one may disable all the default mappings through the option
|g:vimtex_mappings_enabled|. Custom mappings for all desired features must
then be defined through the listed RHS <plug>-maps or by mapping the available
commands.
In the below list of mappings, LHS is the default mapping, RHS is the
corresponding <plug>-maps, and MODE indicates in which vim mode the mappings
are valid.
In addition to the mappings listed below, |vimtex| provides convenient insert
mode mappings to make it easier and faster to type mathematical equations.
This feature is explained in more detail later, see |vimtex-imaps|.
---------------------------------------------------------------------~
LHS RHS MODE~
---------------------------------------------------------------------~
<localleader>li |<plug>(vimtex-info)| `n`
<localleader>lI |<plug>(vimtex-info-full)| `n`
<localleader>lt |<plug>(vimtex-toc-open)| `n`
<localleader>lT |<plug>(vimtex-toc-toggle)| `n`
<localleader>ly |<plug>(vimtex-labels-open)| `n`
<localleader>lY |<plug>(vimtex-labels-toggle)| `n`
<localleader>lv |<plug>(vimtex-view)| `n`
<localleader>lr |<plug>(vimtex-reverse-search)| `n`
<localleader>ll |<plug>(vimtex-compile)| `n`
<localleader>lL |<plug>(vimtex-compile-selected)| `nx`
<localleader>lk |<plug>(vimtex-stop)| `n`
<localleader>lK |<plug>(vimtex-stop-all)| `n`
<localleader>le |<plug>(vimtex-errors)| `n`
<localleader>lo |<plug>(vimtex-compile-output)| `n`
<localleader>lg |<plug>(vimtex-status)| `n`
<localleader>lG |<plug>(vimtex-status-all)| `n`
<localleader>lc |<plug>(vimtex-clean)| `n`
<localleader>lC |<plug>(vimtex-clean-full)| `n`
<localleader>lm |<plug>(vimtex-imaps-list)| `n`
<localleader>lx |<plug>(vimtex-reload)| `n`
<localleader>lX |<plug>(vimtex-reload-state)| `n`
<localleader>ls |<plug>(vimtex-toggle-main)| `n`
dse |<plug>(vimtex-env-delete)| `n`
dsc |<plug>(vimtex-cmd-delete)| `n`
ds$ |<plug>(vimtex-env-delete-math)| `n`
dsd |<plug>(vimtex-delim-delete)| `n`
cse |<plug>(vimtex-env-change)| `n`
csc |<plug>(vimtex-cmd-change)| `n`
cs$ |<plug>(vimtex-env-change-math)| `n`
csd |<plug>(vimtex-delim-change-math)| `n`
tsc |<plug>(vimtex-cmd-toggle-star)| `n`
tse |<plug>(vimtex-env-toggle-star)| `n`
tsd |<plug>(vimtex-delim-toggle-modifier)| `nx`
tsD |<plug>(vimtex-delim-toggle-modifier-reverse)| `nx`
<F7> |<plug>(vimtex-cmd-create)| `nxi`
]] |<plug>(vimtex-delim-close)| `i`
ac |<plug>(vimtex-ac)| `xo`
ic |<plug>(vimtex-ic)| `xo`
ad |<plug>(vimtex-ad)| `xo`
id |<plug>(vimtex-id)| `xo`
ae |<plug>(vimtex-ae)| `xo`
ie |<plug>(vimtex-ie)| `xo`
a$ |<plug>(vimtex-a$)| `xo`
i$ |<plug>(vimtex-i$)| `xo`
aP |<plug>(vimtex-aP)| `xo`
iP |<plug>(vimtex-iP)| `xo`
% |<plug>(vimtex-%)| `nxo`
]] |<plug>(vimtex-]])| `nxo`
][ |<plug>(vimtex-][)| `nxo`
[] |<plug>(vimtex-[])| `nxo`
[[ |<plug>(vimtex-[[)| `nxo`
K |<plug>(vimtex-doc-package)| `n`
---------------------------------------------------------------------~
------------------------------------------------------------------------------
Options~
*vimtex-options*
*g:vimtex_enabled*
Set to 0 to disable |vimtex|.
Default value: Undefined.
*g:vimtex_compiler_enabled*
Use this option to disable/enable the `compiler` interface, see |vimtex-compiler|.
Default value: 1
*g:vimtex_compiler_progname*
Path to vim executable. This is used for the callback functionality, and it
must be set correctly in order for the callback function to work. The
default value should work correctly in most cases, but in some cases, e.g.
for MacVim, one might need to set it manually to get the callbacks to work
as expected.
Default value: |v:progpath| if it exists, else |v:progname|.
*g:vimtex_compiler_callback_hooks*
A list of functions that will be called from the vimtex compiler callback.
The compilation status must be taken as an argument. This allows users to
add custom callback functionality.
Note: The Zathura and MuPDF viewers, if used, add a hook to this list in
order to store the viewer X window ID in order to prevent multiple
viewer windows.
Example: >
let g:vimtex_compiler_callback_hooks = ['MyTestHook']
function! MyTestHook(status)
echom a:status
endfunction
< Default value: []
*g:vimtex_compiler_method*
Set the compiler method. Available choices are:
latexmk~
See |vimtex-latexmk| for more details, and |g:vimtex_compiler_latexmk|
for customization.
latexrun~
See |vimtex-latexrun| for more details, and |g:vimtex_compiler_latexrun|
for customization.
arara~
See |vimtex-arara| for more details, and |g:vimtex_compiler_arara| for
customization.
Default value: 'latexmk'
*g:vimtex_compiler_latexmk*
This is a dictionary that allows customization of the |vimtex-latexmk|
compiler. The values set by the user will take precedence over the default
values.
Default value: >
let g:vimtex_compiler_latexmk = {
\ 'backend' : DEPENDS ON SYSTEM (SEE BELOW),
\ 'background' : 1,
\ 'build_dir' : '',
\ 'callback' : 1,
\ 'continuous' : 1,
\ 'executable' : 'latexmk',
\ 'options' : [
\ '-pdf',
\ '-verbose',
\ '-file-line-error',
\ '-synctex=1',
\ '-interaction=nonstopmode',
\ ],
\}
<
The default value shows which entries may be changed. Here the different
keys are explained in more detail:
backend~
Sets the backend for running processes. Possible values are:
`process` Traditional interface that should work (tm) on all systems.
It uses |!:| to control the compiler processes.
`jobs` Uses |job| to control the processes. This is available on
modern Vim installations. Note that this will start every job
in the background, regardless of the value of the `background`
key. The output may be viewed through |VimtexCompileOutput|.
`nvim` This uses the neovim |job-control| system to control the
compiler process. It is very similar to the `jobs` backend.
The default value is to use the `jobs` or `nvim` backend, if supported,
and fallback to `process` if not.
background~
This option sets whether single shot compilations should be run in the
foreground or the background. Note that it is only relevant for the
`process` backend.
build_dir~
This option sets the compilation build directory. It corresponds to the
`-output-directory` option in `latexmk`. If the path is a relative path,
then it will be considered relative to the main project file.
Note 1: This option only works with `latexmk` version 4.27 and later.
Note 2: If `$out_dir` is added to `.latexmkrc`, then the `.latexmkrc` setting
will have priority.
callback~
If enabled, this option tells `latexmk` to run |vimtex#compiler#callback|
after compilation is finished.
Note 1: This feature requires |clientserver|.
Note 2: The callback is run with the vim executable defined by
|g:vimtex_compiler_progname|.
Note 3: Callbacks are only possible when the `backend` is one of `nvim` or
`jobs`, or when `continuous` is also activated.
continuous~
If enabled, `latexmk` will run in continuous mode, i.e. with the `-pvc`
argument. This means that the document is compiled automatically by
`latexmk` every time a related file has been changed, until the processes
is stopped.
If disabled, `latexmk` will run single shot compilations.
Note: The events |VimtexEventCompileStarted| and |VimtexEventCompileStopped|
are only relevant when this option is enabled.
executable~
The name/path to the `latexmk` executable.
options~
This is a list of options that are passed to `latexmk`. The default
options should work well for most people.
Note: Options may also be specified indirectly to `latexmk` through both
a global and a project specific `.latexmkrc` file. One should know,
though, that options specified on the command line has priority, and
so if one wants to override one of the above default options, then
one has to set this key to a list that contains the desired options.
*g:vimtex_compiler_latexrun*
This is a dictionary that allows customization of the |vimtex-latexrun|
compiler. The values set by the user will take precedense over the default
values.
Default value: >
let g:vimtex_compiler_latexrun = {
\ 'backend' : DEPENDS ON SYSTEM (SEE BELOW),
\ 'background' : 1,
\ 'build_dir' : '',
\ 'options' : [
\ '-verbose-cmds',
\ '--latex-args="-synctex=1"',
\ ],
\}
<
The default value shows which entries may be changed. Here the different
keys are explained in more detail:
backend~
Same as |g:vimtex_compiler_latexmk| / `backend`.
background~
Same as |g:vimtex_compiler_latexmk| / `background`.
build_dir~
Same as |g:vimtex_compiler_latexmk| / `background`.
options~
This is a list of options that are passed to `latexrun`. The default
options should work well for most people.
*g:vimtex_compiler_arara*
This is a dictionary that allows customization of the |vimtex-arara|
compiler. The values set by the user will take precedense over the default
values.
Default value: >
let g:vimtex_compiler_arara = {
\ 'backend' : DEPENDS ON SYSTEM (SEE BELOW),
\ 'background' : 1,
\ 'options' : ['-v'],
\}
<
The default value shows which entries may be changed. Here the different
keys are explained in more detail:
backend~
Same as |g:vimtex_compiler_latexmk| / `backend`.
background~
Same as |g:vimtex_compiler_latexmk| / `background`.
options~
This is a list of options that are passed to `arara`. The default options
should work well for most people.
*g:vimtex_complete_enabled*
Use this option to disable/enable |vimtex| completion.
Default value: 1
*g:vimtex_complete_close_braces*
This option controls whether to append a closing brace after a label or
a citation has been completed.
Default value: 0
*g:vimtex_complete_recursive_bib*
This option toggles recursive searching for bibliography files.
Note: This feature may lead to a significant lag for large projects.
Default value: 0
*g:vimtex_delim_list*
A dictionary that defines the pairs of delimiters that are recognized by
|vimtex| for various commands and functions. The dictionary contains 5 sub
dictionaries:
`env_tex` Pairs of environment delimiters in normal TeX mode
`env_math` Pairs of special math environment delimiters
`delim_tex` Pairs of delimiters in normal TeX mode
`delim_math` Pairs of delimiters in math mode
`mods` Pairs of modifiers for math mode delimiters
Each entry is a dictionary with the following format: >
{
\ 'name' : [
\ ['\(', '\)'],
\ ['\[', '\]'],
\ ['$$', '$$'],
\ ['$', '$'],
\ ],
\ 're' : [
\ ['\\(', '\\)'],
\ ['\\\@<!\\\[', '\\\]'],
\ ['\$\$', '\$\$'],
\ ['\$', '\$'],
\ ],
\}
<
Here the `name` entry is a list of delimiter pairs as they are typed, and the
`re` entry is a corresponding list of regexes that matches the delimiters.
The default value should generally suffice for most people. If one wants to
overwrite one of the main entries, e.g. the `mods` entry, one can do: >
let g:vimtex_delim_list = {
\ 'mods' : {
\ 'name' : [ ... ],
\ }
\}
<
Here the `re` entry was not provided, in which case it will be automatically
generated based on the `name` entry. The remaining four entries will remain
the default value.
*g:vimtex#delim#lists*
*g:vimtex#delim#re*
Note: This option is parsed on plugin initialization into a new variable,
|g:vimtex#delim#lists| where the `re` entries are added and that also
contains some combinations such as `tex_all`, `delim_all`, and `all`.
Further, the option is also used as a basis for the variable
|g:vimtex#delim#re|, which contains full regexes for matching opening
and/or closing delimiters of the desired type.
Default value: See `s:init_delim_lists()` in `autoload/vimtex/delim.vim`.
*g:vimtex_delim_toggle_mod_list*
Defines a list of delimiter modifiers to toggle through using the maps:
|<plug>(vimtex-delim-toggle-modifier)|
|<plug>(vimtex-delim-toggle-modifier-reverse)|
The list must be a subset of the `mods` entry of |g:vimtex_delim_list|,
otherwise the toggle will not work properly. Thus, if one wants to toggle
non-standard delimiters, then one must also update the above option.
Example 1: to toggle between no modifiers, the `\left/\right` pair, and the
`\mleft/\mright` pair, one may use the following options: >
let g:vimtex_delim_list = {'mods' : {}}
let g:vimtex_delim_list.mods.name = [
\ ['\left', '\right'],
\ ['\mleft', '\mright'],
\ ['\bigl', '\bigr'],
\ ['\Bigl', '\Bigr'],
\ ['\biggl', '\biggr'],
\ ['\Biggl', '\Biggr'],
\ ['\big', '\big'],
\ ['\Big', '\Big'],
\ ['\bigg', '\bigg'],
\ ['\Bigg', '\Bigg'],
\]
let g:vimtex_delim_toggle_mod_list = [
\ ['\left', '\right'],
\ ['\mleft', '\mright'],
\]
<
Example 2: to step through no modifiers, and the pairs `\bigl/\bigr`,
`\Bigl/\Bigr`, `\biggl/\biggr`, and `\Biggl/\Biggr`, one may use: >
let g:vimtex_delim_toggle_mod_list = [
\ ['\bigl', '\bigr'],
\ ['\Bigl', '\Bigr'],
\ ['\biggl', '\biggr'],
\ ['\Biggl', '\Biggr'],
\]
<
Default value: `[['\left', '\right']]`
*g:vimtex_delim_stopline*
A tolerance for the number of lines to search for matching delimiters in
each direction. It is used in an expression for the {stopline} argument of
|search()| function calls. If the option is increased it will make the
matching more accurate, at the expense of potential lags. The default value
should work well for most people.
Default value: 500
*g:vimtex_disable_recursive_main_file_detection*
In rare cases, the recursive method of finding the main file in multi file
projects may be slow. This might happen for instance when there are _very_
many tex files in the directory tree that is searched. In such cases, one
may disable the recursive method by setting this variable to a nonzero
value.
Default value: 0
*g:vimtex_doc_handlers*
By default, package documentation is looked up online through
http://texdoc.net/pkg/packagename. With this option, one may specify a list
of custom handlers. A handler is a function that takes a single |Dict|
argument with the following keys:
type~
One of `documentclass`, `usepackage`, `command` or `word`.
candidates~
A list of detected packages (for the types `command` and `usepackage`,
this list may be larger than 1.
selected~
The currently selected entry. This is the package name that will
ultimately be passed to the lookup function.
name~
If the type is `command`, this is the name of the command. Else it is
not defined.
Each handler in the list will be tried until a handler provides a return
value of 1. One may add handlers that only makes minor modifications of the
context and passes it on to the default handler, as well as handlers that
fully completes the lookup e.g. through a local lookup with `texdoc`.
Note that the context may have multiple candidates, and that the handlers
are applied before any internal selection is made. Thus the `selected` key
may not defined. This allows the handler to perform the selection itself, or
one may manually call the selection function `vimtex#doc#make_selection` to
get a simple selection menu.
The following example uses the local `texdoc` to open the documentation: >
let g:vimtex_doc_handlers = ['MyHandler']
function! MyHandler(context)
call vimtex#doc#make_selection(a:context)
if !empty(a:context.selected)
execute '!texdoc' a:context.selected '&'
endif
return 1
endfunction
<
Default value: []
*g:vimtex_echo_ignore_wait*
If enabled, then |vimtex| will remove warning messages faster. This is not
recommended, since the messages are intended to help fix problems one may
have with vimtex configuration.
Default value: 0