URL: http://www.math.fu-berlin.de/~guckes/vim/latex.html URL: https://www.vim8.org/latex.html (mirror) Created: Wed May 29 00:00:00 MET 1996 Last update: Mon Jun 05 12:00:00 MET DST 2000Vim-5 adds "syntax coloring" as a feature to Vim. The syntax file "tex.vim" should contain the necessary info to colorize your LaTeX commands and show math mode in its own color.
Category Name executable ======== ==== ========== Editor VIM vim Typesetter LaTeX latex Viewer GhostView gv Viewer Xdvi dviWARNING: The macros presented here are usually written Vim's "angle notation" which allows to represent special characters to be written out in letters. This allow to copy&paste; them from the screen (terminal) right onto the command line or into the setup file (vimrc). So you cannot use them with Vi, unless you convert them. Sorry.
Some examples:
" ,rl = run latex (on current file) map ,rl :!latex %If you are not familiar with LaTeX then you should know that it will create several files from the tex file, most notably a log file (file.log) which stores all the messages that you get from LaTeX while processing the file.tex, an auxiliary file (file.aux) to keep references and other information, and the resulting "device indepent" (latex.dvi).
After creating the dvi file you will want to check it, ie display it on screen. The most common program available is "GhostView" which displays PostScript files. So we need to produce a PostScript file ("ps file") from the dvi file first. PostScript files have the extension ".ps".
That next macro creates a ps file from a dvi file:
" ,cps = create ps file (from dvi file of current file) map ,cps :!dvips %<.dvi -o:!ghostview %<.ps
imap ^e {\em}TODO:i imap ^b {\bf} i imap ^t {\tt} i imap ^v \verb++ i
map! ]i \item map! ]bi \begin{itemize}\item map! ]ei \end{itemize} map! ]be \begin{enumerate} \item map! ]ee \end{enumerate} map! ]bd \begin{description} \item[ map! ]ed \end{description} map! ]bc \begin{center} map! ]ec \end{center} map! [be{ \samepage \begin{eqnarray} map! [ee\end{eqnarray} } map! ]s1 \section{ map! ]s2 \subsection{ map! ]s3 \subsubsection{ map! ]p1 \paragraph{ map! ]p2 \subparagraph{ map! ]f \frac{ map! ]o \overline{ map! ]u \underline{ map! ;em bi{\em lea} i ab latex \documentstyle[a4]{artikel} \begin{document} \input{titel} \end{document}kki " ================= Block Macros ========================= " =. macro - creates line of "."s of length = column position map =. mx:t. `xjaxD:s/././g " " =* macro - used by block macros: creates line divider: \(...\)\(...\) map =* `a=.xI:s/^A/\\(&\\)\\(/"xdd`b=.@xA\) " " *d macro - delete block from `a (top left) to `b (bot right) map *d =*I:'a,'bs/A\(.*\)/\1\3/"xdd@x " " *D macro - delete from column `a to end of line, over lines 'a,'b map *D `a=.xI:'a,'bs/\(A\).*/\1/"xdd@x " " *y macro - yank `a,`b block onto new lines ('z to 'a-1) map *y =*I:'a,'bg/^/t'a-1|'a-1s/A.*/\2/"xdd'aOmz@x'zddmz " " *t (*T) macro - copy `a,`b block to after (before) cursor map *t my*y`y=.=t map *T my*y`y=.x=t " this should work, but may give "Can't undo in global" message (vi bug?) map =t I:'z,'a-g/[\\&~?]/s//\\&/g :'z,'a-s/\(.*\)/s?\\(A\\)?\\1\1?/"ydd@y:'z,'a-g/^/d x|'y@x|'y+ma y " this works, but is slower and ends with messy "Undefined mark" message " (these are in ~/.viblock2, so if above fails do ":so ~/.viblock2" and redo) "map =t I:'z,'a-g/[\\&~?]/s//\\&/g :'z,'a-s/\(.*\)/s?\\(A\\)?\\1\1?/"ydd@y'akmx*@ "map *@ :'xma x|'zd x|ma z|'y@x jmy*@
Stripping extensions is done with "basename":
"run dvips on document map =d :!dvips `basename % .tex` ^M:e^M^M " " run previewer on dvi version of document map =pr :!prv `basename % .tex`.dvi ^M^M " " run previewer on postscript version of document map =gv :!gv `basename % .tex`.ps & ^M^M " " print .ps version of file map =ps :!pps `basename % .tex`.ps^M^M