/
automatic-tex-plugin.txt
3265 lines (2798 loc) · 126 KB
/
automatic-tex-plugin.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
automatic-tex-plugin.txt For Vim version 7 Last change: 2010 September 2
An Introduction to AUTOMATIC (La)TeX PLUGIN
by Marcin Szamotulski
mszamot [AT] gmail [DOT] com
----------------------------------------
If you found this plugin useful or you have any kind of problems with running
it or some ideas to share, you are cordially invited to write to me:
mszamot@gmail.com. Voting at Vim site is also welcome ;) .
-----------------------------------------------------------------------------
Abstract
This is a filetype plugin for Vim to comfortably write TeX (LaTeX, PdfLaTeX)
documents, which provides functionality not met in other such plugins. It
makes you FREE from compiling procedure, making this process automatic using
autocommands. It also provides useful mappings and other functions: to analyse
your .log file, to see the table contents, to search for a label, to search in
bib files or to find a macro definition matching a pattern, or even to find
and preview fonts in your tex distribution. The features include an extended
tab completion for: commands, environment names, packages, input files, bib
files, bst files, colors, closing brackets and environments (preserves
nesting),... etc. To have full functionality you need: pdffonts available in
the package 'app-text/poppler' (at least in Gentoo). Another good tool is
texdoc, which is a part of texlive - these days standard TeX distribution for
Linux, and MikTeX on Windows.
------------------------------------------------------------------------------
FEATURES INCLUDE:
-----------------
* background compilation with debugging mode
* command to make the document (cross references, references, index, tables
of contents) |atp-:MakeLatex|,
* completion for commands, closing environments (even nested), package names,
citations and labels. Support for some latex packages.
See |atp-Completion|,
* table of contents which allows to switch between different sections, files,
but also to delete and paste sections:
See |atp-:TOC|, |atp-toc-window|,
* list of labels which allows to see the context of a label:
See |atp-:Labels|,
* a powerful function to search in bibliographic files (bib files):
See |atp-bibsearch|,
* a command to list ToDo lines:
See |atp-:ToDo|,
* a command to search for a macro definition (multi-line support):
See |atp-:DefiSearch|,
* a command to search and PREVIEW fonts in your latex distribution:
See |atp-:FontSearch|, and |atp-:FontPreview|,
* indentation
Table of Contents
-----------------------------------------------------------------------------
*atp*
*atp-help-toc*
|atp-news| News
|atp-installation| Installation
|atp-commands| Functions and commands
|atp-toc-window| Commands/maps defined in Table of Contents window
and Labels window.
|atp-bibsearch| Searching in bib files
|atp-completion| How to use and configure completion
|atp-omnicompletion| and omnicompletion (*NEW*)
|atp-configure| How to configure to your needs
|atp-ProjectFiles| A note how to write project files within ATP.
|atp-mappings| Mappings and Commands
|atp-errors| Error handling
|atp-editing| Editing tools
|atp-requirements| Requirements
|atp-viewers| Note about viewers
(including inverse and reverse searching for xdvi)
|atp-tips| Some tex oriented tips
|atp-highlight| Colors and syntax files
|atp-remarks| Final remarks
|atp-copy-rights| Copy Rights
Note on usage: type :help atp<CTRL>d to see all the helptags. To see help tags
for all the defined functions :help atp*()<CTRL>d, mappings: :help atp-map<CTRL>d
================================================================================
NEWS *atp-news*
>
Changes in version 7.5
< Tags in help file for variable are now just the variable names, without
the 'atp-' prefix (after all almost every variable starts with atp).
There is one exception: the LatexBox variables.
*atp-]m*
*atp-[m*
]m, [m goto the beginning of next/previous math environment
*atp-]M*
*atp-[M*
]M, [M goto the beginning of next/previous displayed math environment
*atp-:HelpEnvIMaps*
*atp-:HelpMathIMaps*
*atp-:HelpVMaps*
Help commands: >
:HelpEnvIMaps
:HelpMathIMaps
:HelpVMaps
< They list valid mappings defined by ATP (unless g:no_plugin_maps or
g:no_atp_maps are defined). >
:WriteHistory
< The common history file (which stores some global variables) is
written to the disk if variables have changed. This makes it
fast when there are no changes.
A bug fixed in |atp-:BibSearch|.
The default value of g:atp_mapNn is 0 also for project files.
The variable g:atp_mapNn should be always set as follows (in
|atp-atprc| or |vimrc| file): >
if !exists("g:atp_mapNn")
let g:atp_mapNn = 1
endif
< Then the value will be preserved when atp opens new buffer (for
example when using |atp-:S| command).
<NEW_FEATURE> *atp-:Open*
>
:Open[!] [pattern]
< If you configure g:atp_LibraryPath, this function will find files
matching [pattern] under g:atp_LibraryPath and let them open with
a program defined in >
g:atp_OpenTypeDict
< The g:atp_LibraryPath is a comma-separeted list of directory names.
You can use wildcards '**' and '*' as in |globpath()|.
The default value of g:atp_OpenTypeDict is: >
let g:atp_OpenTypeDict = {
\ "pdf" : "xpdf", "ps" : "evince",
\ "djvu" : "djview", "txt" : "split" ,
\ "tex" : "edit", "dvi" : "xdvi -s 5" }
< The values of g:atp_OpenTypeDict should be a program to open the file,
or one of 'tabe', 'split', 'edit', (if 'vim' is sepcified, then 'tabe'
will be used). The cat program is also supported.
Found files are stored in the variable g:atp_Library. It is set by
|globpath()| on g:atp_LibraryPath and then filtered, only files which
extensions are given in g:atp_OpenTypeDict will be stored. This
variable is restored by the history common file. You can use {bang} !
to regenarete the library if it has changed.
>
:NSSec, :NSec, :NChap, :NPart
:PSSec, :PSec, :PChap, :PPart
< and the correspongin commands are using |atp-:S| command if
g:atp_mapNn is 1 (toggled by |atp-:ToggleNn|). Other wise they use vim
search() function.
<NEW_FEATURE> *atp-:Babel*
>
:Babel
< If g:atp_babel variable is set on start up to 1 (however, the default
value is 0, you can use |vimrc| or |atp-atprc| file to switch it on) then
ATP will set the |'keymap'| option according to the default babel
languege (which is the last language passed to babel as optional
argument [lang_list] in \usepackage[lang_list]{babel}).
*g:atp_keymaps*
The |g:atp_kemaps| variable is used to translate babel language name
to 'keymap' value. The default is something like: >
let g:atp_keymaps = {
\ 'british' : 'ignore', 'english' : 'ignore',
\ 'USenglish' : 'ignore', 'UKenglish' : 'ignore',
\ 'american' : 'ignore',
\ 'bulgarian' : 'bulgarian-bds', 'croatian' : 'croatian',
\ 'czech' : 'czech', 'greek' : 'greek',
\ 'plutonikogreek': 'greek', 'hebrew' : 'hebrew',
\ 'russian' : 'russian-jcuken', 'serbian' : 'serbian',
\ 'slovak' : 'slovak', 'ukrainian' : 'ukrainian-jcuken',
\ 'polish' : 'polish-slash' }
< When the value is <ignore> then the function <SID>Babel() (or the
command |atp-:Babel|) will ignore setting keymap option for this
language. Using the above syntax you can set this variable in |vimrc|
or |atp-atprc| file.
This is useful if you in day to day work use one language, but some
times you write a tex file in some other language.
*g:atp_Compare*
The default value is "changedtick". Then the |b:changedtick-variable|
is used to find if there buffer differs and to run latex. With any other
value a compare function will be used (which compares the buffer and
the written file on the disk) - this method is much slower but has
additional features.
<NEW_FEATURE> *atp-:SyncTex*
>
:SyncTex[!]
:nmap \g
< If you open log file with ':ShowErrors o' command then you can use
this command to move to the place in the source code where the error
occurs. It works with project files and also can go to error which
appear in a declared package. It will go to the first error line
declared in the log file below the cursor position (more precisely, to
frist line which matches '^l\.\d\+\|on input line\|at lines' will be used).
With bang [!] it opens new window if the file with error is not shown
in the current tab page. Without bang it opens the file in the window
where ':ShowErrors o' was used.
*g:atp_SyncLog*
If you set g:atp_SyncLog = 1 (the default value is 0) then the source
file will be syncronized with the log file via autocommand (with
|CursorMoved|). This sets 'cursorline' option to indicate the
corresponding line in the source file. When the log buffer becomes
hidden this option should be unset.
*atp-:Sync*
To set g:atp_SyncLog you can use :Sync command. ':Sync' will toggle
the value, ':Sync on' will set it to 1 and ':Sync off' will set it
to 0.
If you set g:atp_developer = 1 this command will also go to files
under texmf tree (pacakages and classes).
*atp-:SyncXpdf*
*atp-:Xpdf*
*g:atp_SyncXpdfLog*
If you set g:atp_SyncXpdfLog = 1 (the default value is 0) and you use
xpdf as a viewer it will be syncronised with the log file (with
autocommand group |CursorMoved|). You can also use the command
:SyncXpdf or :Xpdf in the log buffer which does the same.
Mappings in log file have been changed: >
]e, [e - go to next/previous error message in log file
]w, [w - go to next/previous warning message in log file
]c, [c - go to next/previous citation warning message in log file
]r, [r - go to next/previous reference warning message in log file
]i, [i - go to next/previous info message in log file
]f, [f - go to next/previous font info message in log file
]p, [p - go to next/previous font package message in log file
]P, [P - go to next/previous page in log file
% - searchpair for (:).
< You can use n/N normal mapping to repeat previous search [count] times.
The last change:
See also |atp-item|.
>
Changes in version 7.4
<
*atp-:TexAlign*
>
:TexAlign
map \a
< This is a wraper around Align command (AutoAlign vim plugin:
http://www.vim.org/scripts/script.php?script_id=884). This command
sets correct align options for LaTeX environments: equation, align,
alignat, flalign, displaymath and tabular. Equation, align, alignat,
flalign and displaymath are checked using syntax, tabular environment
is checked using searchpair() function, the g:atp_completion_limits[2]
applies.
>
:TeXdoc -> :TexDoc
< still under <F1>.
>
:NSSec, :NSec, :NChap, :NPart
:PSSec, :PSec, :PChap, :PPart
< Are using now the atp search function |atp-:S|. This only takes
a difference in project files.
vmaps has changed: >
is -> iS
as -> aS
< This is because there are vim commands is and as (inner/outer
sentence). iS/aS = inner/outer syntax area.
< History feature reviewed: *atp-history*
>
HISTORY FILE
< The directory ftplugin/ATP_files/history under your 'runtimepath'
stores files with values of local variables saved before vim leaved
a buffer (it is very similar to |View|. Local and global variables are
supported. The local variables
which are cached in this way are listed in >
let g:atp_cached_local_variables = [
\ 'atp_MainFile', 'atp_History',
\ 'atp_LocalCommands', 'atp_LocalColors',
\ 'atp_LocalEnvironments', 'TreeOfFiles',
\ 'ListOfFiles', 'TypeDict',
\ 'LevelDict' ]
< The each file will have separate history file which stores the values
of these variables.
*atp-history-common*
There is also common history file, which stores values of global
variables (by default it is ftplugin/ATP_files/history/common_var.vim
The global variables that are written in this file are given in vim
list: >
let g:atp_cached_common_variables = [
\ 'atp_texpackages', 'atp_texclasses' ]
<
If you want to disable this feature for some reason you can set >
let g:atp_History = 0
< or >
let b:atp_History = 0
< If you want to disable this feature only for a given buffer.
(The value of local variable overrides the value of global one!).
Hint: (if you want to disable loading history for one file):
In your .vimrc file you can set the local variable via
autocommand group BufEnter or you can put an if statement in your
|atp-atprc| file: >
if expadn("%:p") == <path_to_file>
let b:atp_History = 0
endif
< If you want to turn off history file for all buffers use: >
au FileType tex let b:atp_History=0
< in vimrc file or 'let b:atp_History = 0' in |atp-atprc| file.
There are these commands: >
:LoadHistory[!]
:WriteHistory[!]
:DeleteHistory[!] [local/common]
:History[!] [on/off]
< which do the obvious thing (if g:atp_History=0 or b:atp_History=0 they
will not work).
:DeleteHistory [local] command (with optional argument [local]) deletes
the history file for the current buffer (only the local one), with
bang "!" it deletes also common history file. The bang of :WriteHistory
forces to write to history file even when history is turned off
(b:atp_History == 0 or !exists("b:atp_History") && g:atp_History == 0).
The command ':History [on/off]' turns on/off History feature for this
buffer (sets b:atp_History). With bang it also sets the global
variable. b:atp_History is by default in the >
g:atp_cached_local_variables
< so it will be restored afterwards. b:atp_History if defined overrides
the value of global variable g:atp_History. So you can set in your atp
file g:atp_History = 0 and for some files using the if-construction: >
let g:atp_History = 0
if expand("%:t") == "myfile.tex"
let b:atp_History = 1
endif
< will turn on the History feature only for myfile.tex. Something more
elaborate would be to set b:atp_History only for files with
modification time less than two days for example.
Note: If you delete the history file for the current buffer it will be
written after exiting vim, unless you turn off the history feature.
The history is disabled for files which full path matches 'texmf',
which should not be statically related to any file. The optional bang
loads history also for them. :WriteHistory command will write
the history disregarding if the file is under texmf directory or not.
Note: If you use this feature, you might need to use some times the
commands: |atp-:LocalCommands| and |atp-:InputFiles| which will update
b:atp_LocalCommands, b:atp_LocalColors, b:atp_LocalEnvironments and
b:TreeOfFiles, b:ListOfFiles, b:TypeDict and b:LevelDict. Then use
these commands with a bang "!" (:LocalCommands!, :InputFiles!). The
second set of variables is also updated by |atp-:S| (also with "!"a
and GotoFile.
Note: Also when you add a package to tex you should remove the common
history file, so that the new packages will be added to completion
list.
The history directory is configurable via the variable: >
let g:atp_history_dir
< The default value is 'ftplugin/ATP_files/history'.
>
Changes in version 7.3.7
< Numerous Fixes +
|atp-:DeleteSection|, |atp-:PasteSection|, |atp-:SectionStack| and |atp-:Undo|,
|atp-highlight-notification|.
>
Changes in version 7.3.4 and 7.3.6
< (in 7.3.6 I added :DeleteHistory[!] [file], see below.)
Changes in: |atp-:DefiSearch|, |b:atp_running|, |atp-visual|,
|atp-gw|, |atp-g<|, |atp-g>|, |g:atp_sort_completion_list|.
>
nmap gf, :GotoFile, :EditInputFile
< a command which behaves like 'gf' was added. With the minor
difference, it always gives the choice which input file to edit,
regardless of the position of the cursor.
The current file is now also shown, with highlight group: |hl-WarningMsg|.
:S[!] /{pattern}/ [flag]
Now, it sets the alternate file to the buffer from which the search begun.
This means that if {pattern} was found the alternate file before search
will be lost. It gives a handy way to come back after a search.
The pattern can be '\\input'. Then it goes recursively to the first
input line.
Now it also doesn't search inside commented input files. There two
commands: >
:NInput
:PInput
< and two mappings: >
]gf
[gf
< which finds the next/previous input line (also commented). See
|atp-:S_input| to find how it works.
:BibSearch [pattern] [flag]
Lines of bib file are matched against the pattern. Before the match
are ligature symbols and {,} are removed. For example \`a, \' e,
\oa,\ea are substituted with a, e, oa, ea (respectively). Note that
the space in \' e is also removed.
:Viewer *atp-:Viewer*
Command which help to set b:atp_Viewer variable (with completion)
:Compiler *atp-:Compiler*
Command which help to set b:atp_TexCompiler variable (with completion)
:DebugMode *atp-:DebugMode*
Command which help to set b:atp_DebugMode variable (with completion)
>
New Features in version 7.3.1 (some changes after version 7.3)
<
Some things works faster in this version: generating the lables and
recursive looking for input files (using vimgrep).
:GotoFile, :EditInputFile
nmap gf
To go to file over a cursor or it let choose an input
file from the list. Over:
\input{<fname>}, \input <fname>, \include{<fname>}
it edits the <fname>
If g:atp_developer is set to one also works over:
\documentclass{<classname>}, \usepakcage{<packagename}
Otherwise, i.e if the cursor position is not over any
of the above it lets you choose which input file to
use.
The current file is now shown with highlight group:
|hl-WarningMsg|.
:MakeLatex[!] |atp-:MakeLatex|
With one command you can make your whole document:
cross references, bibliography, index, table of
contents. ':MakeLatex!' should be used when you
deleted an entry from bibliography (when you use
'bibtex' this means when you deleted last citation
command with the entry).
> *atp-:S*
:S[!] /{pattern}/ [flags]
Changes after version 7.3: The E and S flags are
removed. The pattern is a vim pattern (with
'magic'). With bang ! it regenerates the tree
of input files.
This is command does the same job as |/| but is
recursive in the tree of files (so it is useful only
in project files). The syntax of this command is
similar to |:vimgrep|.
This works similarly to |:ijump|. But also goes back
to the root file (b:atp_MainFile).
It sets the alternate file to the buffer from which
the search begun. That means if no search was found
the alternate file before search will be lost.
The {pattern} is any vim pattern as desribed in
|pattern| (it was only tested with 'magic' set on).
The supported flags are 'bcewW' (see |search()|).
You can enclose the pattern with any non-ID character
(see |'isident'|) instead of /, as far as it does not
appear in the {pattern}. Examples: >
:S pattern\_swith\_sspaces
< will work but: >
:S pattern with spaces
< will not.
There is a new function to check where the input file
is on the hard drive if the name in the input command
doesn't include the full path. It asks kpsewhich which
directories to search, filters out some directories
(which are not under '/home', I assume that there is
your local texmf tree, and also directories which name
contains one of the two keywords 'texlive' and
'kpsewhich'). This makes the searching faster.
*atp-:S_input*
Furthermore, the command is designed so that it can find
all patterns '\\input' (and thus easily find next/previous
input file). You can use: >
:S \\input
:S \\input b
< and you can use 'n' and 'N' vim normal commands. Note
that it if you go backward, then it means that it will
find the most deep line, e.g.: >
file.tex
----
----
\input{file.1} ----> -------
-------
\input{file.1.1}
-------
----X
< ':S /\\input/ b' in the X position fill find
\input{file.1.1} assuming file.1.1.tex doesn't inputs
any other file.
*atp-:ToggleNn* >
:ToggleNn
< Switches on/off them nmaps n,N to the recursive
search. If these maps are defined n and N use
recursive search.
Mappings are defined with nore (':h noremap') so they work even when
the Special Space map is on (see |atp-:ToggleSpace|)
>
New Features in version 7.2.1
<
See: |atp-completion-labels|, |atp-atprc|, |atp-debug-mode|, |b:atp_TexFlavor|.
>
New Features in version 7.1
<
See: |g:atp_MathVimOptions|.
================================================================================
INSTALLATION *atp-installation*
>
:filetype plugin on is required to run this plugin, see
|:filetype-plugin-on| and |:filetype-indent-on| if you want to have
automatic indentation for TeX files. Also |:syntax on| is required as
several features (but not basic ones) requieres syntax.
<
To install you just need to copy tex.Vim file to ~your ~/.Vim/ftplugin/
directory copy this help file to ~/.Vim/doc and then run :helptags ~/.Vim/doc
and that's all, now you can just type your story ... :)
If you do not like colors you can still set syntax on but clear the highlight
colors (you should make a simple function which clears all the highlight
groups, because ':hi clear' will not give you what you want).
================================================================================
COMMANDS *atp-commands* *atp-:*
The main function is not seen by the user (it is called s:compiler, for those
who want to read the plugin). It executes tex compiler specified by the
variable b:atp_TexCompiler. It is executed
as an autocommand by the line:
au! CursorHold $HOME*.tex silent call 's:auTeX()'
where s:auTeX() is a simple function which calls s:compiler if the file written
on the disk and the buffer differ.
As you can see it will run if a key is not pressed during time defined by
option 'updatetime' (see |CursorHold|) in the normal mode. If you type in
insert mode the file won't be compiled (and that's alright as you can be in the
middle of your very long formula). The value of 'updatetime' which works fine
is around 1000ms ('updatetime' is set in milliseconds). Tex compiler is run with
one options:
-output-directory
which points to a unique temporary file in Vim temporary directory (using the
function 'tempname()' (see |tempname()|. If you are concerned with security
reasons read also: |shelltemp|.
You can switch off/on the function s:auTeX by pressing <S-F5> or by letting
the local to buffer variable b:autex=1 (on) b:autex=0 (off). It is useful in
some situations turn automatic compiling off. The key <S-F5> calls the function
ToggleAuTex() which sets the variable b:autex and issue a message. You can also
set this variable to 0 for some files that are not supposed to be processed,
for example:
>
au BufRead texmf/*.tex let b:atp_autex=0
<
On start up b:atp_autex is set to 1 if the path of opened file is not under any
tex directory ('kpsewhich -show-path tex', except the current dir). For example,
files located under your local texmf tree will have b:atp_autex=0.
The second important variable b:atp_TexCompiler (see |b:atp_TexCompiler|) configures
if you use TeX, PdfTeX, LaTeX, PdfLaTeX and it should point to the program
name so please do not use capital letters.
Next variable to set is b:atp_OutDir (see |b:atp_OutDir|). It configures where TeX
will put the output and where viewer and log analyzing tools can find
appropriate files.
The last top most important variable is |g:keep| which is a list of extensions,
by default it is
let g:keep = ["log","aux","toc","bbl"]
Files with this extension will be copied from b:atp_OutDir to the temporary
directory with appropriate name to be used when (La)TeX is compiling. (log file
will be only copied after it is created, other files will be copied back and
forth between you b:atp_OutDir and the temporary directory)
|atp-callback|
|atp-debug-mode|
By default the call back mechanism is turned on (g:atp_callback=1)
When call back mechanism is set, which is by default if you run gui
version, if you invoke 'vim' from command line you need to add
'servername' variable, it might be desirable to alias vim to to >
vim --servername VIM
< you have additional functionalities:
* STATUS LINE NOTIFICATION: status line can show if tex is running >
let g:atp_status_notification = 1
< If unset you will get a message when compiler ends.
If set the number next to the name of your compiler indicates
how many instances are currently running.
* The LOG FILE will be automatically read after compilation.
* if t:atp_DebugMode = 'silent'
You will not get any message from compilation.
= 'debug'
After the end of compilation (invoked by the user
or autocommand) you will get a message with the
return status of the compilator.
If you open the error window with :copen or with
the menu option ToggleDebugMode then it will be
automatically closed after first compilation with
exist status 0.
= 'verbose'
Every compilation which is invoked by the user will
be run in verbose mode as with <F5> key.
Note: the 'verbose' mode in 'vim' (in console) needs to be run, when
there is no other latex instance running. Now you get a message to
wait until compilation ends. In future releases, a better solution
will be worked out. Gui version 'gvim' works better (as it doesn't
suspend the editor).
The background compilation is always done in g:atp_DefaultDebugMode.
Unless it is set to 'verbose' in which case 'debug' mode is used.
You can invoke compiler in the 'debug' mode with '<LocalLeader>d',
'<LocalLeader>l' uses the default mode.
*b:atp_ReloadOnError*
The variable b:atp_ReloadOnError if set to 1 (the default) reload the file
even when the exit status of compiler was non zero. If set to 0, then the file
will not be reloaded [actually for viewers other than xpdf it will not be
copied from the temporary directory, for xpdf it will be copied but not
reloaded).
There is also a variable which stores the last command which executed
your tex compiler, see |g:texcommand|.
Below I explain commands (functions) which are accesible:
:{runs}TEX [debug_mode] *atp-:TEX*
map \l, map \d
If anyway you want to run TeX yourself but you do not want to see the
output this is the right tool. This runs TeX in 'nonstopmode'. You can
specify an argument {runs} which tells how many consecutive runs of
TeX you need (this is important if you want to compile Table of
Contents, or index, or the bibliography (see |atp-:Bibtex|)
If b:atp_OpenViewer=1 and there current viewer (b:Viewer) is not
running on the output file then this function will open a viewer. By
default b:atp_OpenViewer=0 and this feature is disabled.
The command :2TEX will call the compiler two times.
It is useful when you want to make the outline (using hyperref
package) of your article in pdf files, the tex file has to be
'sourced' twice. To make the bibliography you can use |atp-:Bibtex|.
If {runs} > 5 it will be reduced to 5, to avoid running tex for hundreds
(or event thousands) of times (what could happen otherwise by
a mistake giving the range of the command to be the current line
number).
The optional argument [debug_mode] has possible valus: '', 'silent',
'debug', 'verbose'. When '' the value of g:atp_DefaultDebugMode is
used. See the description of |atp-debug-mode|.
\d is mapped to :TEX debug and \l to :TEX (thus it uses your default
debug mode).
:DTEX *atp-:DTEX*
map <F5>,imap <F5>
This is equivalent to ':TEX debug'.
*atp-:MakeLatex*
:MakeLatex[!]
With one command you can make your whole document: cross references,
bibliography (with or without bibtex), index, table of contents, table
of figures, table of theorems ([ntheorem package]), table of
algorithms. ':MakeLatex!' should be used when an entry from
bibliography was deleted (when 'bibtex' is involved this is when you
delete last citation command of a bib entry).
:ShowErrors [flag] *atp-:ShowErrors*
This command shows error/warning messages. It sets the |'errorformat'|
variable accordingly to the optional [flag] argument, which is a word
made of letters:
>
e - include errors
w - include all warning messages
r - include all reference warnings
c - include all citations warnings
f - include all font warnings
fi - include font info massages
F - show files listed in the log
(messages which start with 'File: ')
shows the files loaded by tex
for example fd files that LaTeX is using
p - show packages loaded by tex
(messages which start with 'Package: ')
all - show all the log file
o - open the log file in a new buffer (split).
<
If none flag is given 'e' is used. If 'o' flag is uesd the split
buffer with log message has a map 'q' to ':bd'.
Example: >
:ShowErrors rc
< will show all reference and citation warnings.
ShowErrors maps: *atp-:ShowErrors-maps*
<F6>+e to see all errors (:ShowErrors e)
<F6>+w to see all warnings (:ShowErrors w)
<F6>+r to see warnings coming (:ShowErrors rc)
from references or citations
<F6>+f to see font warnings (:ShowErrors f)
this is not a texloganalyzer mapping but it is a good place to mention it:
<F6>+l to open log file in a new split window
this is a mapping to the |atp-:OpenLog|.
:SetErrorFormat {flag} *atp-:SetErrorFormat*
This command has the same syntax as :ShowErrors. It only sets the
|'erroformat'| variable.
:Bibtex[!] [debug_mode] *atp-:Bibtex*
map \b
This function will call bibtex to produce the bibliography file
(.bbl). If in |b:atp_OutDir| there is no 'aux' file it first calls tex
compiler. After the 'bbl' file is produced two consecutive runs of tex
compiler are called to make the bibliography.
If you specify any value to the [debug_mode] option then then this function
will be called in verbose mode (only the last time tex compiler will
run in errorstop mode). This gives you the chance to see the output of
bibtex command for a second. The command :Bibtex v is associated to
this behaviour. If you want to just run bibtex see the next function.
The command :Bibtex will :call Bibtex(), while :Bibtex v
(and :Bibtex [debug_mode]) will :call Bibtex(1)
For the description of optional argument [debug_mode] see |atp-:TEX|.
*g:atp_raw_bibinputs*
Tex is looking for the date base files in the path: `kpsewhich
-show-path bib`. The variable g:atp_bibinputs contains
these directories separated by commas. If atp cannot find your
bib file, tex also won't be able.
*g:atp_raw_texinputs*
Similarly this variable stores all of path reported by `kpsewhich
-show-path tex`.
*g:atp_bibinputs*
This is a list of directories as g:atp_raw_bibinputs with appended '**'
see ':h file-searching'.
*g:atp_texinputs*
This is a list of directories as g:atp_raw_texinputs with appended '**'
see ':h file-searching'.
:ViewOutput *atp-:ViewOutput*
map \v,map <F3>, imap <F3>
You would like to see what you are editing use this function. It will
use the program defined in the variable b:atp_Viewer. See |b:atp_Viewer|,
|g:atp_XpdfServer|, |atp-xpdfOptions|. When there is no output file it will run
TeX and open the file. Read more about particular viewers
(inverse/reverse searching) in |atp-viewers|.
:SetXdvi *atp-:SetXdvi*
This command sets the options for xdvi viewer, which enables inverse
and reverse searching. It sets the command >
:RevSearch
map \rs
< For inverse searching hold CTRL and click left mouse button on
the text in xdvi viewer.
:SetXpdf *atp-:SetXpdf*
This command sets the options for xpdf viewer (as for now the
inverse/reverse searching in pdf files is not implemented)
It will read the xpdf viewer options from the variables
b:atp_xpdfOptions and g:atp_xpdfOptions.
:BibSearch [pattern] [flag] see |atp-:BibSearch|
This function finds bib entries in bib files defined in your tex file
and in the variable b:atp_BibFiles (see |b:atp_BibFiles|), which match the
[pattern] (a vim regular expression). The output is configurable by
the [flag] argument, see |atp-bibflags|.
:BibChoose see |atp-:BibChoose|
map c, map y, map p
This function is defined in the window with results of BibSearch
command. It is mapped to 'y' and 'c' and let you copy the bib entry key
to a register (see |atp-:BibChoose|) or directly to last opened
buffer (after the last cursor position). When you chose to paste, it
will close the BibSearch window.
:FindBibFiles *atp-:FindBibFiles*
This updates the variables s:bibfiles, s:allbibfiles,
s:notreadablebibfiles. Finds all bib files defined in all
'\bibliography' commands. For more about the above variables read
|atp-variables-bib|. This function is called internally be the script
functions BibSearch/BibChoose. The command :FindBibFiles finds bib
files in the current buffer.
If a readable bib file was not found under one of path listed in of
g:atp_bibinputs variable (see |g:atp_bibinputs|) it is classified
as not readable.
:GotoFile[!] *atp-:GotoFile*
:EditInputFile[!] / the old name /
nmap gf
This command finds input files under b:atp_MainFile (it is recursive).
The nmap 'gf' checks first if there is a file under the cursor.
This command uses kpsewhich to find in which path to find input files.
Actually the path variables: |g:atp_texinputs| for input files and
|g:atp_bibinputs| for bib files are used.
The bibliographis declared are also listed. The command searches for
them in any directory listed in g:atp_bibinputs (see
|g:atp_bibinputs|).
If g:atp_developer = 1 (default 0) then the map 'gf' can also open
package files and document class files.
With bang "!" this command regenerates tree of files (this is
important only in files with input lines), without it uses cached
values (if they exist).
The current file is now shown with highlight group: |hl-WarningMsg|.
:ShowErrors o *atp-:OpenLog*
:OpenLog, map <F6>l, imap <F6>l
Opens log file in a new split window with two options (which are set
locally): 'ruler', 'nospell', and a map 'q' to ':bd'.
You can also use the command ':Explore' to see log, aux, ... files
(which is a part of 'netrw' vim plugin).
:Delete[!] *atp-:Delete*
map <F6>d
Deletes all files which extension belongs to g:atp_tex_extensions in
the directory b:atp_OutDir. By default g:atp_tex_extensions does not
contain '.tex', '.pdf', '.dvi' so none of your important files will be
deleted. When the command is used with bang it also deletes the
current output file.
:SshPrint [printer], [printer_options] *atp-:SshPrint*
It will run 'lpr' command and append to it the options defined in the
variable 'g:printeroptions' + options given in the second argument. It
prints the pdf or dvi depending on the value of 'b:atp_TexCompiler' (see
|b:atp_TexCompiler|). If you specify the variable
'g:atp_ssh=<user>@<host>' it will print via ssh on the <host> using
the [printer]. The command ':SshPrint' has a completion set for the
printers available on your local system or in the host. All the
arguments of the command SshPrint are |<f-args>|.
Both arguments are optional (the default system printer is used, and
only the options 'g:printeroptions' apply).
The command has completion for the names of printers (also remote
printers), press <Tab> to cycle through printers, or type first
letters of the printers name and press <Tab> to complete it.
*atp-:Lpstat*
:Lpstat
Sends "lpstat -l" remotely (using the 'g:atp_ssh' value) or locally and
echoes the output.
*atp-:ShowOptions*
:ShowOptions[!] [pattern]
This will show values of variables that are currently set.
With bang it also shows global variables defined in
'ftplugin/ATP_files/options.vim' (that means almost all global
variables). Completion lists are filtered out by default.
The optional argument [pattern] is used to filter variables names with
the given pattern.
TIP: if you are looking for a variable you can use this command to
find it.
*atp-:WrapSelection*
:WrapSelection {beginWrapper}, [endWrapper], [cursor_pos], [new_lines]
Puts selected text inside begin_wrapper: [endWrapper] and sets the
cursor position according to the variables [cursor_pos]. Possible values
are: a number (indicates the character of {beginWrapper} to put the
cursor on (see and check vmap \c below), or 'end' put the cursor at
the end of [endWrapper] or 'begin' leave the cursor at the beginning
(to be precise at the end of the starting wrapper).
The default [endWrapper] is '}'. The last argument [new_lines]
0/1 (default is 0): if 1 then the begin_wrapper and end_wrapper are put
in seperate lines (the begin line and end line are split), this is
useful for putting text into and environment \begin{}:\end{}.
The command arguments should be separated with commas and quoted
separately (see |<args>|).
*atp-:InteligentWrapSelection*
:InteligentWrapSelection {mathWrapperPair}, {textWrapperPair}, [cursor_pos], [new_lines]
Puts the selected text inside {mathWrapperPair} if the cursor stands
in mathematics otherwise inside {textWrapperPair}.
{mathWrapperPair} {textWrapperPair} are vim lists of length at
least 1, the first wrapper is the opening and the second is the
closing one (if not given the default '}' is used. The other arguments
are as for |atp-:WrapSelection|. If the opening leader in is not
given then this command is not wrapping the text (see below for the
suggested map '\tx')
The command arguments should be separated with commas and quoted
separately (see |<args>|).
These are the provided maps in visual mode: >
vmap <buffer> \rm :<C-U>InteligentWrapSelection ['\\textrm{'], ['\\mathrm{']<CR>
vmap <buffer> \em :<C-U>InteligentWrapSelection ['\\emph{'], ['\\mathit{']<CR>
vmap <buffer> \it :<C-U>InteligentWrapSelection ['\\textit{'], ['\\mathit{']<CR>
vmap <buffer> \sf :<C-U>InteligentWrapSelection ['\\textsf{'], ['\\mathsf{']<CR>
vmap <buffer> \tt :<C-U>InteligentWrapSelection ['\\texttt{'], ['\\mathtt{']<CR>
vmap <buffer> \bf :<C-U>InteligentWrapSelection ['\\textbf{'], ['\\mathbf{']<CR>
vmap <buffer> \bb :<C-U>InteligentWrapSelection ['\\textbf{'], ['\\mathbb{']<CR>
vmap <buffer> \sl :<C-U>WrapSelection '\\textsl{'<CR>
vmap <buffer> \sc :<C-U>WrapSelection '\\textsc{'<CR>
vmap <buffer> \up :<C-U>WrapSelection '\\textup{'<CR>
vmap <buffer> \md :<C-U>WrapSelection '\\textmd{'<CR>
vmap <buffer> \n :<C-U>InteligentWrapSelection ['\\textnormal{'],['\\mathnormal{']<CR>
vmap <buffer> \cal :<C-U>InteligentWrapSelection [''],['\\mathcal{']<CR>
vmap <LocalLeader>f :WrapSelection '{\usefont{'.g:atp_font_encoding.'}{}{}{}\selectfont ', '}',(len(g:atp_font_encoding)+11)<CR>
< Suggested maps: >
vmap <buffer> \tx :<C-U>InteligentWrapSelection [''],['\\text{']<CR>
vmap <buffer> \in :<C-U>InteligentWrapSelection [''],['\\intertext{']<CR>"
< The leader '\' in above commands is configurable: the value of
g:atp_vmap_text_font_leader is used (the default is '\').
Another provided wrapper: >
vmap <buffer> \f :WrapSelection
\ '{\\usefont{".g:atp_font_encoding."}{}{}{}\\selectfont ', '}', '(len(g:atp_font_encoding)+11)'<CR>
< Where the variable: >
g:atp_font_encoding
< stores the default encoding which is 'OT1', unless you use fontenc
package, then the default for fontenc is used (the last defined in
\usepackage[...]{fontenc} see the 'Latex2e font selection'
/font user guide/ available on CTAN).
Other wrappers: >
vmap m :WrapSelection '\(', '\)'<CR>
vmap M :WrapSelection '\[', '\]'<CR>
vmap <LocalLeader>( :WrapSelection '(', ')', 'begin'<CR>
vmap <LocalLeader>[ :WrapSelection '[', ']', 'begin'<CR>
vmap <LocalLeader>{ :WrapSelection '{', '}', 'begin'<CR>
vmap <LocalLeader>) :WrapSelection '(', ')', 'end'<CR>
vmap <LocalLeader>] :WrapSelection '[', ']', 'end'<CR>
vmap <LocalLeader>} :WrapSelection '{', '}', 'end'<CR>
vmap <LocalLeader>b( :WrapSelection '\left(', '\right)', 'begin'<CR>
vmap <LocalLeader>b[ :WrapSelection '\left[', '\right]', 'begin'<CR>
vmap <LocalLeader>b( :WrapSelection '\left(', '\right)', 'begin'<CR>
vmap <LocalLeader>b[ :WrapSelection '\left[', '\right]', 'end'<CR>
vmap <LocalLeader>b{ :WrapSelection '\left{', '\right}', 'end'<CR>
vmap <LocalLeader>b{ :WrapSelection '\left{', '\right}', 'end'<CR>
< And the maps to put the selected text into an environment: >
vmap <LocalLeader>C :WrapSelection '\begin{center}', '\end{center}', '0','1'<CR>
vmap <LocalLeader>R :WrapSelection '\begin{flushright}', '\end{flushright}', '0','1'<CR>
vmap <LocalLeader>L :WrapSelection '\begin{flushleft}', '\end{flushleft}', '0','1'<CR>
< (note that the arguments for this command must be put in ':' or ":")
the highlighted text will put inside \textbf{ }.
You can also use a wrapper which was yanked into register 'a': >
:WrapSelection @a
< This will work not only in visual mode. It will operate on last
selected text. So if you accidentally lost the selection you can still
use this command (but not the maps)!
:TOC[!] *atp-:TOC*
nmap \t
Shows Table of Contents of your document. It do not yet support the
started version of chapter, section,... environments.
The optional argument bang controls if the table of contents data base
must be generated: by default map \t doesn't regenerate the toc data
base (unless if it doesn't exist), :TOC command regenerate the
data base, :TOC! ]ot.
See |atp-toc-window| for commands and maps defined in the toc window.
TOC() supports many edited files. For example if you have in your
buffer list two files a.tex and b.tex this command will produce table
of contents of both of them. If you have just one opened window
(excluding the ToC window) then pressing <space>, <enter>, p and q
will take you to the right buffer (which will be read if is unloaded
or hidden). If you split a window then <space>, <enter>,
p, q will take you to the window from which you are coming. However,
if you have two windows with two different buffers loaded they will
act on the window with the matching buffer name.