" file: texmacro.vim " current version at http://sites.netscape.net/benjif/vim/ " tex-related macros for vim " version 0.03 " Last modified: Fri Mar 10, 2000 13:33:54 Eastern Standard Time " author: Benji Fisher " Table of Contents " 1. Summary " 2. Installation " 3. Functions that invoke external commands " 4. Functions that do automatic formatting " 4a. Ralf Arens's AUC-TeX inspired functions for LaTeX environments " 5. Menu definitions " 6. Autocommands " 1. Summary " There is more documentation in the file texviman.txt at the above URL. " Note that you can search for the next section with '/^" \d' " The Table of Contents above provides a pretty good idea of the structure " of this file. My general strategy is to define functions to do anything " interesting. I also define a menu item to call most functions, but I define " very few key mappings. This is because I do not want to interfere with the " mappings you may have defined. When the menu is closed, it only takes up a " little bit of real estate in your menu list; even if you never use menus, " this will not (I hope) be too annoying. " " Every function and non-local variable that I define starts with "TeX_". " " This file is sourced the first time you enter a tex file. It first looks " for a file in your main vim directory, which is where you should put your " customizations. This file should be called texvimrc.vim: an example is " provided and should be in the same directory as this file. " It will also look for a texvimrc file in the $HOME directory. if filereadable(expand("$VIM/texvimrc.vim")) source $VIM/texvimrc.vim endif if filereadable(expand("$HOME/texvimrc.vim")) source $HOME/texvimrc.vim endif " If PushOption() is not available, look for it in this directory " and in the usual places. Remove the GetOptionsFromFile() function " because it may be used by document viruses. if !exists("*PushOption") if filereadable(expand("$HOME/buffoptions.vim")) source $HOME/buffoptions.vim elseif filereadable(expand("$VIM/buffoptions.vim")) source $VIM/buffoptions.vim elseif filereadable( expand(":h") . "/buffoptions.vim" ) " We need the colon for the Mac version. \ || filereadable( expand(":h") . ":buffoptions.vim" ) execute "source " . expand(":h") . "/buffoptions.vim" endif if exists("*GetOptionsFromFile") delfunction GetOptionsFromFile endif endif " 2. Installation " There is more documentation in the file texviman.txt at the above URL. " Make a directory (folder) within your main vim directory " or your $HOME directory; the recommended " name for this file is TeX, but you can use any name you like. Move this " file, and related ones, to this directory. Copy the file texvimrc.vim to " $VIM or $HOME and modify it to your liking. If you want to define " additional TeX autocommands, place them in a file texauto.vim in the same " directory as texvimrc.vim. (Again, a sample file is provided.) That's it! " 3. Functions that invoke external commands " let " let function! TeX_DVI() cd %:p:h w if exists("g:TeX_dvioptions") let opt = g:TeX_dvioptions else let opt = "" endif execute '!latex ' . opt . ' ' . escape(expand('%'), ' ') endfunction fun! TeX_DVIview() if exists("g:TeX_dviviewer") let viewer = g:TeX_dviviewer elseif has("win32") let viewer = "yap" else let viewer = "xdvi" endif let viewer = substitute(viewer, "%l", line("."), "g") let viewer = substitute(viewer, "%f", expand("%:t"), "g") if has("win32") let viewer = 'start ' . viewer endif execute '!' . viewer . " " . expand("%:p:r") endfun function! TeX_PDF() cd %:p:h w !pdftex % endfunction fun! TeX_PDFview() if exists("g:TeX_PDFviewer") let viewer = g:TeX_PDFviewer else echo "Sorry, you have to set a viewer in texvimrc.vim" return endif execute '!start D:\Adobe\Acroba~1.0\Reader\Acrord32 ' . \ expand("%:p:r") . '.pdf' endfun " 4. Functions that do automatic formatting " Assume the cursor is on a " and return TeX-style open quotes or close " quotes appropriately. " TODO: Deal with nested quotes. function! TeX_quote() let l = line(".") let c = col(".") if synIDattr(synID(l, c, 1), "name") =~ "^texMath" \ || (c > 1 && getline(l)[c-2] == '\') return '"' endif if exists("g:TeX_open") let open = g:TeX_open else let open = "``" endif if exists("g:TeX_close") let close = g:TeX_close else let close = "''" endif let boundary = '\|' if exists("g:TeX_strictquote") if( g:TeX_strictquote == "open" || g:TeX_strictquote == "both" ) let boundary = '\<' . boundary endif if( g:TeX_strictquote == "close" || g:TeX_strictquote == "both" ) let boundary = boundary . '\>' endif endif let q = open let ws_save = &wrapscan set wrapscan " so the search will not fail while 1 " Look for preceding quote (open or close), ignoring " math mode and '\"' . execute 'normal ?^$\|"\|' . open . boundary . close . "\r" if synIDattr(synID(line("."), col("."), 1), "name") !~ "^texMath" \ && (col(".") == 1 || getline(".")[col(".")-2] != '\') break endif endwhile " Now, test whether we actually found a _preceding_ quote; if so, is it " and open quote? if ( line(".") < l || line(".") == l && col(".") < c ) if strlen(getline(".")) if ( getline(".")[col(".")-1] == open[0] ) let q = close endif endif endif " Return to line l, column c: execute l . " normal " . c . "|" let &wrapscan = ws_save return q endfunction " " Usage: :let bar = 3 | TeXLine bar put='% comment' " command! -nargs=* TeXLine " \ | execute 'let TeX_Line_range=' . matchstr(, '\S\+') " \ | execute TeX_Line_range . substitute(, '\S\+', "", "") " \ | unlet TeX_Line_range " Usage: :let foo = 1 | let bar = 3 | TeXRange foo bar s/foo/bar command! -nargs=* TeXRange \ execute 'let TeX_Range_range=' . substitute(, \ '\(\S\+\)\s\+\(\S\+\).*', '\1.",".\2', "") \ | exe TeX_Range_range . substitute(, '\S\+\s\+\S\+', "", "") \ | unlet TeX_Range_range fun! TeX_matrix(...) range let save_report = &report set report =1000 " Suppress messages from :s if exists("a:1") let env = a:1 else let env = "bmatrix" endif TeXRange a:firstline a:lastline s/\t/ \&/eg if a:firstline < a:lastline TeXRange a:firstline (a:lastline-1) s/$/ \\\\/ endif TeXRange a:firstline a:lastline s/^/ / call append(a:lastline, '\end{' . env . '}') call append(a:firstline-1, '\begin{' . env . '}') let &report = save_report endfun fun! TeX_determinant() range TeXRange a:firstline a:lastline call TeX_matrix("vmatrix") endfun fun! TeX_unmatrix() range let save_report = &report set report =1000 " Suppress messages from :s TeXRange a:firstline a:lastline s/ \&/\t/eg TeXRange a:firstline a:lastline s/ \\\\$//e TeXRange a:firstline a:lastline s/^ //e execute a:lastline . "d" execute a:firstline . "d" let &report = save_report endfun fun! TeX_cases() range " Stop-gap until I change the vmaps and menu items TeXRange a:firstline a:lastline call TeX_matrix("cases") endfun " Do an elementary row operation fun! TeX_Row_op(vector, scalar) execute "normal A\t\0" let v = a:vector while strlen(v) let bar = matchstr(v, "[^\t]*") let v=strpart(v, 1+strlen(bar), strlen(v)) execute "normal ct\t\=@\"+a:scalar*bar\\w" endwhile .-1s/\t$// + endfun fun! TeX_Row_reduce() let v = @" let s = input("Enter the multiple: ") call TeX_Row_op(v, s) let @" = v endfun " Take the transpose of a matrix. fun! TeX_transpose() range let save_reg = @" let save_report = &report set report=1000 " Just in case we are at the end of the file execute a:lastline . "put=''" " Start out by counting tabs and making sure every line has the same number. let maxtab = 0 let l = a:firstline while l <= a:lastline let ntab = strlen(substitute(getline(l), '[^\t]', "", "g")) if ntab > maxtab let maxtab = ntab endif let l = l + 1 endwhile let maxtab = maxtab + 1 let l = a:firstline while l <= a:lastline let ntab = strlen(substitute(getline(l), '[^\t]', "", "g")) execute l . "normal" . (maxtab-ntab) . "A\t\" let l = l + 1 endwhile " Now, convert the first row into a column. execute a:firstline . 's/\t/\t\r/g' | d let n = a:lastline - a:firstline " For each of the remaining rows, make it into a column, delete it, " and put it at the end of the matrix. while n s/\t/\t\r/g d execute "normal 0k" if maxtab > 1 execute "normal \" . (maxtab-1) . "k$d" . maxtab . "k$p" else execute "normal \$d" . maxtab . "k$p" endif execute '.+' . maxtab . ',.+' . (2*maxtab) . 'j' let n = n-1 endwhile execute a:firstline . "," . (a:firstline+maxtab-1) . 's/\t$//' execute (a:firstline+maxtab) . "d" let &report = save_report let @" = save_reg endfun " Convert a tab-formatted line of coefficients into a linear equation. fun! TeX_equation() s/.*\t/\0 = / let n = 1 let line = getline(".") while match(line, "\t") != -1 let line = substitute(line, "\t", " x_{" . n ."} + ", "") let n = n+1 endwhile call setline(line("."), line) s/+\s*=/\t=\t s/+\s*-/- /eg s/\<1\s*x/x/eg endfun fun! TeX_System_of_eqns() range let save_report = &report set report =1000 " Suppress messages from :s TeXRange a:firstline a:lastline g/\t/call TeX_equation() TeXRange a:firstline a:lastline call TeX_matrix('eqnarray*') let &report = save_report endfun " Specialized: convert a list of problem numbers into section, " subsection, and subsubsection. fun! TeX_exercise_list() let save_report = &report set report =1000 " Suppress messages from :s s/^.\{-}[Ss]ection\s*\(\d*\)/\\setcounter{section}{\1} s/\.\(\d*\)/ \\setcounter{subsection}{\1}\r put='\addtocounter{subsection}{-1}' put='\subsection{}' execute "normal kkddjpd/\\d\" s/\*//eg s/\s*\(\d\+\)[,;.]\=/\r\\setcounter{subsubsection}{\1} \ \\addtocounter{subsubsection}{-1}\r\\subsubsection{}\r/eg let &report = save_report endfun " 4a. Ralf Arens's AUC-TeX inspired functions for LaTeX environments " TODO: I have lots of plans. For now, I am pretty much pasting them in as " Ralf Arens wrote them. For now, I will only modify them so that they start " with "TeX_" and provide menu entries for them. " some macros for LaTeX " " by Ralf Arens " Thu 27 Jan 2000, 15:24:58 CET " inspired by AUC TeX's `LaTeX-environment' " " map `:call TeX_ask_env()' and `TeX_read_env()' to convient shortcuts " this asks for an environment and " inserts \begin{...} and \end{...} commands function! TeX_ask_env() let env = input("Environment? ") call TeX_common_env(env) endfunction " this reads the current and creates an environment out if it " (this way you can use ins-completion) function! TeX_read_env() let env = getline(".") normal ddk call TeX_common_env(env) endfunction " common routine for all environments function! TeX_common_env(env) if (a:env=="figure" || a:env=="figure*" ) call TeX_figure(a:env) elseif (a:env=="table" || a:env=="table*") call TeX_table(a:env) elseif (a:env=="tabular" || a:env=="tabular*" || \a:env=="array" || a:env=="array*") call TeX_tabular(a:env, "") elseif (a:env=="eqnarray" || a:env=="equation*") call TeX_eqnarray(a:env) elseif (a:env=="list") call TeX_list(a:env) elseif (a:env=="itemize" || a:env=="theindex" || \a:env=="trivlist" || a:env=="enumerate") call TeX_itemize(a:env) elseif (a:env=="description") call TeX_description(a:env) elseif (a:env=="document") call TeX_document(a:env) elseif (a:env=="minipage") call TeX_minipage(a:env) elseif (a:env=="thebibliography") call TeX_thebibliography(a:env) else put ='\begin{'.a:env.'}' put ='\end{'.a:env.'}' endif endfunction " special treatment for `figure' function! TeX_figure(env) let flto = input("Float to (htbp)? ") "let pos = input("Position (htbp)? ") let caption = input("Caption? ") let center = input("Center (y/n)? ") " confirm is also possible, but I don't like it (in a terminal) "let center = confirm("Center?", "&yes\n&no") let label = input('Label (for use with \ref)? ') " additional to AUC TeX since my pics are usually external files let pic = input("Name of Pic-File? ") " " what should hapen if flto is empty? default values? nothing? put ='\begin{'.a:env.'}['.flto.']' put ='\end{'.a:env.'}' normal k if (center == "y") put =' \begin{center}' put =' \end{center}' normal m' normal k endif if (pic != "") put =' \input{'.pic.'}' endif if (caption != "") put =' \caption{'.caption.'}' endif if (label != "") put =' \label{'.label.'}' endif normal '' endfunction " special treatment for `table' function! TeX_table(env) let flto = input("Float to (htbp)? ") let caption = input("Caption? ") let center = input("Center (y/n)? ") " confirm is also possible, but I don't like it (in a terminal) "let center = confirm("Center?", "&yes\n&no") let label = input('Label (for use with \ref)? ') " TODO what should hapen if flto is empty? default values? nothing? put ='\begin{'.a:env.'}['.flto.']' put ='\end{'.a:env.'}' normal k if (center == "y") put =' \begin{center}' put =' \end{center}' normal k endif normal m' if (caption != "") put =' \caption{'.caption.'}' endif if (label != "") put =' \label{'.label.'}' endif normal '' call TeX_tabular("tabular", " ") endfunction " special treatment for `tabular' and `array' function! TeX_tabular(env, indent) let foo = a:indent.'\begin{'.a:env.'}' let pos = input("(Optional) Position (t b)? ") if (pos!="") let foo = foo.'['.pos.']' endif let format = input("Format ( l r c p{width} | @{text} )? ") put =foo.'{'.format.'}' put =a:indent.'\end{'.a:env.'}' normal k endfunction " special treatment for `eqnarray' and `equation' function! TeX_eqnarray(env) let label = input("Label? ") put ='\begin{'.a:env.'}' if (label != "") put =' \label{'.label.'}' endif put ='\end{'.a:env.'}' normal k endfunction " special treatment for `list' (unlike AUC TeX) function! TeX_list(env) let label = input("Label (for \item)? ") let foo ='\begin{'.a:env.'}' if (label != "") let foo = foo.'{'.label.'}' let addcmd = input("Additional commands? ") if (addcmd != "") let foo = foo.'{'.addcmd.'}' endif endif put =foo put ='\end{'.a:env.'}' normal k put =' \item' endfunction " special treatment for `itemize', `enumerate', `theindex', `trivlist' function! TeX_itemize(env) put ='\begin{'.a:env.'}' put ='\end{'.a:env.'}' normal k put =' \item' endfunction " special treatment for `description' function! TeX_description(env) put ='\begin{'.a:env.'}' put ='\end{'.a:env.'}' normal k let itlabel = input("(Optional) Item label? ") if (itlabel == "") put =' \item' else put =' \item['.itlabel.']' endif endfunction " special treatment for `document' function! TeX_document(env) let dstyle = input("Document style (article report book)? ") let opts = input("(Optional) Options? ") let foo = '\documentclass' if (opts=="") let foo = foo.'{'.dstyle.'}' else let foo = foo.'['.opts.']'.'{'.dstyle.'}' endif put =foo put ="" put ='\begin{document}' put ='\end{document}' normal k endfunction " special treatment for `minipage' function! TeX_minipage(env) let foo = '\begin{minipage}' let pos = input("(Optional) Position (t b)? ") let width = input("Width? ") if (pos=="") let foo = foo.'{'.width.'}' else let foo = foo.'['.pos.']{'.width.'}' endif put =foo put ='\end{minipage}' normal k endfunction " special treatment for `thebibliography' function! TeX_thebibliography(env) let foo = '\begin{thebibliography}' " AUC TeX: "Label for BibItem: 99" let indent = input("Indent for BibItem? ") let foo = foo.'{'.indent.'}' let biblabel = input("(Optional) Bibitem label? ") let key = input("Add key? ") let bar = ' \bibitem' if (biblabel!="") let bar = bar.'['.biblabel.']' endif let bar = bar.'{'.key.'}' put =foo put =bar put ='\end{thebibliography}' normal k endfunction " set makeprg, errorformat for LaTeX " BF: I will trust RA on this, but move this to a different section. " " let LaTeX report multiple errors " set makeprg=latex\ \\\\nonstopmode\ \\\\input\\{$*} " " multi-line error-messages " set efm=%E!\ LaTeX\ %trror:\ %m, " \%E!\ %m, " \%+WLaTeX\ %.%#Warning:\ %.%#line\ %l%.%#, " \%+W%.%#\ at\ lines\ %l--%*\\d, " \%WLaTeX\ %.%#Warning:\ %m, " \%Cl.%l\ %m, " \%+C\ \ %m., " \%+C%.%#-%.%#, " \%+C%.%#[]%.%#, " \%+C[]%.%#, " \%+C%.%#%[{}\\]%.%#, " \%+C<%.%#>%.%#, " \%C\ \ %m, " \%-GSee\ the\ LaTeX%m, " \%-GType\ \ H\ %m, " \%-G\ ...%.%#, " \%-G%.%#\ (C)\ %.%#, " \%-G(see\ the\ transcript%.%#), " \%-G%*\\s, " \%+O(%f)%r, " \%+P(%f%r, " \%+P\ %\\=(%f%r, " \%+P%*[^()](%f%r, " \%+P[%\\d%[^()]%#(%f%r, " \%+Q)%r, " \%+Q%*[^()])%r, " \%+Q[%\\d%*[^()])%r " BF: This was already commented out by RA. " add ditionary for insert-mode completion "set dictionary+=~/.vim/LaTeX.dic " add mapping for inset-mode completion "imap   " useless, use  or  without any mappings " BF: I have my own mechanism for this! " " environment command " "map ülf :call TeX_figure() " map üle :call TeX_ask_env() " map üld :call TeX_read_env() " " section cmds ,l1 ,l2 ,l3 " map ül1 I\section{}ha " map ül2 I\subsection{}ha " map ül3 I\subsubsection{}ha " " ,L invokes LaTeX on current file " map üL :!latex %:!dvips %<.dvi -o:!gv %<.ps " " quickfix, vorbereitungen " "map ,lq :!bash -e 'latex -interaction=nonstopmode % | tee error.log' " "map ülq :!latex -interaction=nonstopmode % \| tee error.log " BF: This was already commented out by RA. " labels " figure fig: " table tab: " eqnarray eq: " BF: This was RA's modeline. " vim:et:ts=4 " 5. Menu definitions " TODO: Divide these into submenus. " If g:TeX_DVI_key = '\d' then " :call TeX_menuMaker("nv", "make &DVI", "DVI", "pre", "a,b", "post") " will generate the commands " nmenu 45 Te&X.make\ &DVI\\d pre:call TeX_DVI(a,b)post " nmap \d pre:call TeX_DVI(a,b)post " and the corresponding vmenu/vmap commands. Call with prefix="" or " " to " generate "menu" and "map" commands. " Hack: To generate menu and map commands that do not call a function, " define g:TeX__key and call with function="" and pre="whatever". fun! TeX_menuMaker(prefix, menuItem, function, ...) if a:0 > 0 let command = a:1 else let command = "" endif if a:function != "" let command = command . ":call TeX_" . a:function endif if a:0 < 2 let command = command . "()" else let command = command . "(" . a:2 . ")" if a:0 > 2 let command = command . a:3 endif endif " Done: the right-hand side of the map/menu has been built up. if a:prefix == "" let prefix = " " else let prefix = a:prefix endif if exists("g:TeX_" . a:function . "_key") execute "let binding = g:TeX_" . a:function . "_key" else let binding = "" endif while strlen(prefix) if binding == "" exe prefix[0]."menu 45 Te&X." . escape(a:menuItem, '\ ') . " " . command else execute prefix[0] . "menu 45 Te&X." . escape(a:menuItem, '\ ') \ . '' . escape(binding, '\') . " " . command if prefix[0] != "a" if exists("*PushOption") call PushOption( prefix[0]."map ".binding, command) else execute prefix[0] . "map " . binding . " " . command endif else " Do "amap" to emulate "amenu". if exists("*PushOption") call PushOption( "nmap ".binding, command, \ "vmap ".binding, ' '.command, \ "omap ".binding, ' '.command, \ "imap ".binding, ' '.command, \ "cmap ".binding, ' '.command) else execute "map " . binding . " \" . command execute "nmap " . binding . " " . command execute "imap " . binding . " \" . command execute "cmap " . binding . " \" . command endif endif endif let prefix = substitute(prefix, ".", "", "") endwhile endfun fun! TeX_menus() " echo "TeX_menus" call TeX_menuMaker("a", "generate &DVI", "DVI") call TeX_menuMaker("a", "&view DVI", "DVIview") call TeX_menuMaker("a", "generate &PDF", "PDF") call TeX_menuMaker("a", "view PDF", "PDFview") call TeX_menuMaker("a", "&Environment (prompt)", "ask_env") call TeX_menuMaker("a", "Environment (©)", "read_env") call TeX_menuMaker("nv", "Make Determinant", "determinant") call TeX_menuMaker("nv", "Make Matrix", "matrix") call TeX_menuMaker("nv", "Undo Matrix", "unmatrix") call TeX_menuMaker("nv", "Make Cases", "cases") call TeX_menuMaker("nv", "Exercise List", "exercise_list") let path = "&Linear Algebra." call TeX_menuMaker("nv", path . "&Equation", "equation") call TeX_menuMaker("nv", path . "&System", "System_of_eqns") call TeX_menuMaker("nv", path . "&Row Reduce", "Row_reduce") call TeX_menuMaker("nv", path . "&Transpose", "transpose") endfun " fun! TeX_unmenus() " I think the following line will suffice. " aunmenu TeX " aunmenu Te&X.&Insert.&Equation " aunmenu Te&X.Run\ &tex " aunmenu Te&X.Preview " endfun " 6. Autocommands " TODO: path, define, include, makeprg, errorformat, ef, mef, linebreak and " breakat(?), complete, dictionary, infercase, showmatch, matchpairs, " shiftwidth, smarttab, softtabstop, autoindent, suffixes " Group autocommands under the heading "TeX": augroup TeX " Remove all TeX autocommands: in particular, remove the autocommand " that sources this file. au! " Options that are local to the buffer " (so far, only two) " " Break lines (at a word boundary) after 78 characters. This works well " for ordinary text. You may find it annoying for complicated " equations, tables, and so on. I wish I could find a way to change 'tw' " depending on the TeX mode... " " Adding '\' to 'isk' works well if you use dictionary completion or avoid " stringing TeX escapes together like "$\alpha\neq\beta$". The docs are not " clear: I will have to experiment with adding the k flag to 'complete'. " Does the order of the flage in 'complete' matter? If so, I can put k in " first... autocmd FileType tex set tw=78 isk+=\ " " Options and mappings that need to be defined/undefined when " switching buffers " TODO: use Michael Geddes's buffoptions.vim method. " " Invoke TeX_quote() by typing " in Insert or Replace mode. autocmd BufEnter *.tex,*.sty inoremap " \ ":let@9=TeX_quote()9 autocmd BufLeave *.tex,*.sty iunmap " " BF: I will trust RA on this, but move this to a different section. " Set the makeprg and errorformat strings: needs testing! " let LaTeX report multiple errors let TeX_mp = 'latex \\nonstopmode \\input\{$*}' " multi-line error-messages let TeX_efm = '%E! LaTeX %trror: %m,' . \ '%E! %m,' . \ '%+WLaTeX %.%#Warning: %.%#line %l%.%#,' . \ '%+W%.%# at lines %l--%*\d,' . \ '%WLaTeX %.%#Warning: %m,' . \ '%Cl.%l %m,' . \ '%+C %m.,' . \ '%+C%.%#-%.%#,' . \ '%+C%.%#[]%.%#,' . \ '%+C[]%.%#,' . \ '%+C%.%#%[{}]%.%#,' . \ '%+C<%.%#>%.%#,' . \ '%C %m,' . \ '%-GSee the LaTeX%m,' . \ '%-GType H %m,' . \ '%-G ...%.%#,' . \ '%-G%.%# (C) %.%#,' . \ '%-G(see the transcript%.%#),' . \ '%-G%*\s,' . \ '%+O(%f)%r,' . \ '%+P(%f%r,' . \ '%+P %\=(%f%r,' . \ '%+P%*[^()](%f%r,' . \ '%+P[%\d%[^()]%#(%f%r,' . \ '%+Q)%r,' . \ '%+Q%*[^()])%r,' . \ '%+Q[%\d%*[^()])%r' "Now for the autocommands! if !exists("*PushOption") autocmd BufEnter *.tex,*.sty call TeX_menus() autocmd BufLeave *.tex,*.sty aunmenu TeX autocmd BufEnter *.tex,*.sty let TeX_mp_save=&mp | let TeX_efm_save=&efm \ | let &mp = TeX_mp | let &efm = TeX_efm autocmd BufLeave *.tex,*.sty let &mp=TeX_mp_save | let &efm=TeX_efm_save else autocmd FileType texEnter call TeX_menus() autocmd FileType texLeave aunmenu TeX autocmd FileType texEnter call PushOption("mp", TeX_mp, "efm", TeX_efm) autocmd FileType texLeave call RestoreOptions() endif augroup END if filereadable(expand("$VIM/texauto.vim")) source $VIM/texauto.vim endif " We need the colon form for the Mac OS. if filereadable( expand(":h") . "/texauto.vim" ) \ || filereadable( expand(":h") . ":texauto.vim" ) execute "source " . expand(":h") . "/texauto.vim" endif if filereadable(expand("$HOME/texauto.vim")) source $HOME/texauto.vim endif " This file is sourced, and the TeX autocommands are defined, the first time " a file of FileType TeX is entered, so we do these commands now: if &ft == "tex" " Skip if I am editing this file and source it manually! doautocmd TeX FileType tex doautocmd TeX BufEnter * endif