" " File: latex-mik.vim " Purpose: LaTeX support (MikTeX) for GVIM on Win32-systems " Version: 0.6 " Author: Volker Kiefel " " Documentation of this script may be found in latex-mik.pdf, source of " documentation: latex-mik.tex. " " For installation, please put this file (latex-mik.vim) into the vim " plugin-directory " " This script adds a menu for LaTeX-related functions for .tex, .bib-files " " Usage: " To process multiple file LaTeX-projects, enter the project name (e.g. " ``myproject'') at the prompt, if ``myproject.tex'' is the main file. " " Menu options address " " (pdf)latex " bibtex " makeindex " yap (dvi-viewer) " dvips " gsview32 " tth " " Latex-mik supports entering commands, environments and BibTeX entries. " " This script is distributed in the hope that it will be useful, " but WITHOUT ANY WARRANTY; without even the implied warranty of " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. " " V0.1: initial upload " v0.2: unused code removed " v0.3: BibTeX document type unpublished corrected " v0.4: Documentation added " v0.5: Documentation corrected " v0.6: Environment definitions completed; the most important commands have " mapped to `,la' (LaTeXProject) `,vi' (ViewFile) etc.; documentation " updated " " M.Vrdoljak, 2003,2004: lokalne promjene, prilagodbe i dodaci "-- prema auctex-u let mapleader = '`' let my_mapleader = ';' "-- nastavak latex-mik.vim :function! Standard_map() :map! ä \"a :map! ö \"o :map! ü \"u :map! Ä \"A :map! Ö \"O :map! Ü \"U :map! ß {\ss} :set isk+=58,46 :endfunction :function! GetProjName() let s:projektname = input("Enter project name [default current file]: ") if (s:projektname=="" || s:projektname==" ") let s:projektname = expand("%:t:r") endif echo " (".s:projektname.")" :endfunction :function! ExeYap() if exists("s:projektname") == 0 call GetProjName() return endif let s:zlnr=line(".") let befehl="silent !yap -s ".s:zlnr.expand("%:t")." ".s:projektname.".dvi" execute(befehl) :endfunction :function! ExeLatex() if exists("s:projektname") == 0 call GetProjName() return endif " let befehl="silent !latex -src ".s:projektname let befehl="!latex --src-specials ".s:projektname execute(befehl) :endfunction :function! Exedvips() if exists("s:projektname") == 0 call GetProjName() return endif let befehl="!dvips ".s:projektname execute(befehl) :endfunction :function! Exedvipsps() if exists("s:projektname") == 0 call GetProjName() return endif let befehl="!dvips -Ppk ".s:projektname execute(befehl) :endfunction :function! ExeTexify() if exists("s:projektname") == 0 call GetProjName() return endif let befehl_="silent !latex --src-specials ".s:projektname let befehl1="silent !bibtex ".s:projektname let befehl2="silent !latex --src-specials ".s:projektname let befehl3="silent !latex --src-specials ".s:projektname execute(befehl_) execute(befehl1) execute(befehl2) execute(befehl3) :endfunction :function! ExeTexifyPS() if exists("s:projektname") == 0 call GetProjName() return endif let befehl_="silent !latex --src-specials ".s:projektname let befehl1="silent !bibtex ".s:projektname let befehl2="silent !latex --src-specials ".s:projektname let befehl3="silent !latex --src-specials ".s:projektname let befehl4="!dvips -Ppk ".s:projektname execute(befehl_) execute(befehl1) execute(befehl2) execute(befehl3) execute(befehl4) :endfunction :function! ExeTexifyPSLight() if exists("s:projektname") == 0 call GetProjName() return endif let befehl_="silent !latex --src-specials ".s:projektname let befehl1="!dvips -Ppk ".s:projektname execute(befehl_) execute(befehl1) :endfunction :function! Exegsv() if exists("s:projektname") == 0 call GetProjName() return endif " let befehl="!gsview32 ".s:projektname.".ps" let befehl="!gv ".s:projektname.".ps" execute(befehl) :endfunction :function! ExePDFLaTeX() if exists("s:projektname") == 0 call GetProjName() return endif " let befehl="silent !pdflatex ".s:projektname let befehl="!pdflatex ".s:projektname execute(befehl) :endfunction :function! ExeBibtex() if exists("s:projektname") == 0 call GetProjName() return endif let befehl="!bibtex ".s:projektname execute(befehl) :endfunction :function! Exetohtml() if exists("s:projektname") == 0 call GetProjName() return endif let befehl="!tth ".s:projektname.".tex" execute(befehl) :endfunction :function! ExeMakeindex() if exists("s:projektname") == 0 call GetProjName() return endif let befehl="!makeindex ".s:projektname execute(befehl) :endfunction :function! Remove_map() :call Standard_map() :unmap! ä :unmap! ö :unmap! ü :unmap! Ä :unmap! Ö :unmap! Ü :unmap! ß :unmap! š :unmap! ð :unmap! è :unmap! æ :unmap! ž :unmap! Š :unmap! Ð :unmap! È :unmap! Æ :unmap! Ž :set isk-=58,46 :endfunction :function! German_map() :map! ä "a :map! ö "o :map! ü "u :map! Ä "A :map! Ö "O :map! Ü "U :map! ß "s :endfunction :function! Croatian_map() :map! š \v{s} :map! è \v{c} :map! æ \'{c} :map! ž \v{z} :map! Š \v{S} :map! È \v{C} :map! Æ \'{C} :map! Ž \v{Z} :map! ð {\dj} :map! Ð {\DJ} :endfunction :function! Bibtex_map() :map! ä {\"a} :map! ö {\"o} :map! ü {\"u} :map! Ä {\"A} :map! Ö {\"O} :map! Ü {\"U} :map! ß {\ss} :endfunction :function! Deutsche_umschreibungen_map() :map! ä ae :map! Ä Ae :map! ö oe :map! Ö Oe :map! ü ue :map! Ü Ue :map! ß ss :endfunction :function! Empty_env() :let umgebung = input("Enter environment Name: ") :if strlen(umgebung) == 0 :echo "Environment aborted" :return :elseif umgebung == "itemize" || umgebung == "enumerate" :let ausgabe = "\\begin{".umgebung."}\n \\item \n\\end{".umgebung."}" :put!=ausgabe :elseif umgebung == "description" :let ausgabe = "\\begin{".umgebung."}\n \\item[] \n\\end{".umgebung."}" :put!=ausgabe :elseif umgebung == "minipage" :let envoption = input("Enter minipage type for latex209 or latex2e [209, 2e]: ") :if envoption == "2e" :let ausgabe = "\\begin{".umgebung."}[][][]{}\n\n\\end{".umgebung."}" :else :let ausgabe = "\\begin{".umgebung."}[]{}\n\n\\end{".umgebung."}" :endif :put!=ausgabe :elseif umgebung == "tabular" :let ausgabe = "\\begin{".umgebung."}[]{}\n\n\\end{".umgebung."}" :put!=ausgabe :elseif umgebung == "array" :let ausgabe = "\\begin{".umgebung."}[]{}[]\n\n\\end{".umgebung."}" :put!=ausgabe :elseif umgebung == "table" || umgebung == "figure" :let ausgabe = "\\begin{".umgebung."}[]\n\n \\caption[]{}\n \\label{}\n\\end{".umgebung."}" :put!=ausgabe :elseif umgebung == "theorem" :let ausgabe = "\\begin{".umgebung."}{}[]\n\n\\end{".umgebung."}" :put!=ausgabe :else :let ausgabe = "\\begin{".umgebung."}\n\n\\end{".umgebung."}" :put!=ausgabe :endif :endfunction :function! Plain_env() :if visualmode() != "V" :echo "No text highlighted linewise" :return :endif :let umgebung = input("Enter environment Name: ") :if strlen(umgebung) == 0 :echo "Environment aborted" :return :elseif umgebung == "itemize" || umgebung == "enumerate" :let head = "\\begin{".umgebung."}\n \\item " :let tail = "\n\\end{".umgebung."}" :elseif umgebung == "description" :let head = "\\begin{".umgebung."}\n \\item[] " :let tail = "\n\\end{".umgebung."}" :elseif umgebung == "minipage" :let envoption = input("Enter minipage type for latex209 or latex2e [209, 2e]: ") :if envoption == "2e" :let head = "\\begin{".umgebung."}[][][]{}\n" :let tail = "\n\\end{".umgebung."}" :else :let head = "\\begin{".umgebung."}[]{}\n" :let tail = "\n\\end{".umgebung."}" :endif :elseif umgebung == "tabular" :let head = "\\begin{".umgebung."}[]{}\n" :let tail = "\n\\end{".umgebung."}" :elseif umgebung == "array" :let head = "\\begin{".umgebung."}[]{}[]\n" :let tail = "\n\\end{".umgebung."}" :elseif umgebung == "table" || umgebung == "figure" :let head = "\\begin{".umgebung."}[]\n" :let tail = "\n \\caption[]{}\n \\label{}\n\\end{".umgebung."}" :elseif umgebung == "theorem" :let head = "\\begin{".umgebung."}{}[]\n" :let tail = "\n\\end{".umgebung."}" :else :let head = "\\begin{".umgebung."}\n" :let tail = "\n\\end{".umgebung."}" :endif :let @m = tail :normal `> :normal "mp :let @m = head :normal `< :normal "mP :endfunction :function! Empty_com() :let befehl = input("Enter command Name: ") :if strlen(befehl)==0 :echo "Command aborted" :return :elseif befehl == "newcommand" || befehl == "renewcommand" :let @m = "\\".befehl."{}[]{}" :normal "mPhhhh :elseif befehl == "multicolumn" :let @m = "\\".befehl."{}{}{}" :normal "mPhhhh :elseif befehl == "colorbox" || befehl == "textcolor" :let @m = "\\".befehl."{}{}" :normal "mPhh :elseif befehl == "usepackage" || \ befehl == "foilhead" || \ befehl == "includegraphics" :let @m = "\\".befehl."[]{}" :normal "mPhh :elseif befehl == "verb" :let @m = "\\".befehl."++" :normal "mP :else :let @m = "\\".befehl."{}" :normal "mP :endif :endfunction :function! Plain_com() :if visualmode() != "v" :echo "No text highlighted characterwise" :return :endif :let befehl = input("Enter command Name: ") :if strlen(befehl)==0 :echo "Command aborted" :return :elseif befehl == "newcommand" || befehl == "renewcommand" :let head = "\\".befehl."{}[]{" :let tail == "}" :elseif befehl == "multicolumn" :let head = "\\".befehl."{}{}{" :let tail = "}" :elseif befehl == "colorbox" || befehl == "textcolor" :let head = "\\".befehl."{}{" :let tail = "}" :elseif befehl == "usepackage" || \ befehl == "foilhead" || \ befehl == "includegraphics" :let head = "\\".befehl."[]{" :let tail = "}" :elseif befehl == "$" :let head = "$" :let tail = "$" :elseif befehl == "\"" :let head = "\"`" :let tail = "\"'" :elseif befehl == "'" :let head = "``" :let tail = "''" :elseif befehl == "verb" :let head = "\\".befehl."+" :let tail = "+" :else :let head = "\\".befehl."{" :let tail = "}" :endif :let @m = tail :normal `> :normal "mp :let @m = head :normal `< :normal "mP :endfunction :function! LatexUnMenu() unmenu &LaTeX :endfunction :function! LatexMenu() menu 8000.10.010 &LaTeX.BibTeXE&ntry.&Article i@article{,author = {},title = {},year = {},journal = {},OPTpages = {},OPTvolume = {},OPTmonth = {},OPTnumber = {}} menu 8000.10.020 &LaTeX.BibTeXE&ntry.B&ook i@book{,ALTauthor = {},ALTeditor = {},title = {},year = {},publisher = {},OPTaddress = {},OPTedition = {}} menu 8000.10.020 &LaTeX.BibTeXE&ntry.Bookle&t i@booklet{,ALTauthor = {},title = {},OPThowpublished = {},OPTaddress = {},OPTyear = {},OPTmonth = {}} menu 8000.10.030 &LaTeX.BibTeXE&ntry.I&nbook i@inbook{,ALTauthor = {},ALTeditor = {},title = {},OPTtype = {},year = {},publisher = {},OPTaddress = {},ALTpages = {},ALTchapter = {},OPTedition = {}} menu 8000.10.040 &LaTeX.BibTeXE&ntry.&Incollection i@incollection{,author = {},OPTeditor = {},title = {},booktitle = {},year = {},publisher = {},OPTpages = {},OPTaddress = {},OPTedition = {}} menu 8000.10.050 &LaTeX.BibTeXE&ntry.Inproce&edings i@inproceedings{,author = {},title = {},booktitle = {},year = {},OPTeditor = {},OPTvolume = {},OPTnumber = {},OPTnumber = {},OPTseries = {},OPTpages = {},OPTaddress = {},OPTmonth = {},OPTorganization = {},OPTpublisher = {},OPTnote = {}} menu 8000.10.060 &LaTeX.BibTeXE&ntry.Manua&l i@manual{,title = {},OPTauthor = {},OPTorganization = {},OPTaddress = {},OPTedition = {},OPTmonth = {},OPTyear = {},OPTnote = {}} menu 8000.10.070 &LaTeX.BibTeXE&ntry.Masterst&hesis i@mastersthesis{,author = {},title = {},school = {},year = {},OPTtype = {},OPTaddress = {},OPTmonth = {},OPTnote = {}} menu 8000.10.080 &LaTeX.BibTeXE&ntry.Mi&sc i@misc{,OPTauthor = {},OPTtitle = {},OPThowpublished = {},OPTmonth = {},OPTyear = {},OPTnote = {}} menu 8000.10.090 &LaTeX.BibTeXE&ntry.&Phdthesis i@phdthesis{,author = {},title = {},school = {},year = {},OPTtype = {},OPTaddress = {},OPTmonth = {},OPTnote = {}} menu 8000.10.100 &LaTeX.BibTeXE&ntry.P&roceedings i@proceedings{,title = {},year = {},OPTeditor = {},OPTvolume = {},OPTnumber = {},OPTseries = {},OPTaddress = {},OPTpublisher = {},OPTnote = {}OPTmonth = {},OPTmonth = {},OPTorganization = {}} menu 8000.10.110 &LaTeX.BibTeXE&ntry.Te&chreport i@techreport{,title = {},author = {},institution = {},year = {},OPTtype = {},OPTnumber = {},OPTaddress = {},OPTmonth = {},OPTnote = {}} menu 8000.10.120 &LaTeX.BibTeXE&ntry.&Unpublished i@unpublished{,author = {},title = {},OPTmonth = {},OPTyear = {},note = {}} menu 8000.10.900 &LaTeX.-sep1- vmenu 8000.20 &LaTeX.&Environment\ on\ Region,ren :call Plain_env() nmenu 8000.22 &LaTeX.Empty\ &Environment,en :call Empty_env() vmenu 8000.25 &LaTeX.&Commands\ on\ Region,rcm :call Plain_com() nmenu 8000.25 &LaTeX.Empty\ &Commands,cm :call Empty_com() menu 8000.28.010 &LaTeX.-sep2- menu 8000.40.020 &LaTeX.&Umlaute.Normal\ &TeX :call Standard_map() menu 8000.40.030 &LaTeX.&Umlaute.&No\ mapping :call Remove_map() menu 8000.40.040 &LaTeX.&Umlaute.&German\ TeX\ mapping :call German_map() menu 8000.40.050 &LaTeX.&Umlaute.&BibTeX\ mapping :call Bibtex_map() menu 8000.40.070 &LaTeX.&Umlaute.German\ &Umlaut\ mapping :call Deutsche_umschreibungen_map() menu 8000.40.080 &LaTeX.&Umlaute.&Croatian\ mapping :call Croatian_map() menu 8000.50.010 &LaTeX.-sep4- menu 8000.60 &LaTeX.&LaTeXProject,la :call ExeLatex() menu 8000.61 &LaTeX.&BibTeXProject,lb :call ExeBibtex() menu 8000.62 &LaTeX.&IndexProject :call ExeMakeindex() menu 8000.70 &LaTeX.&ViewFile,vi :call ExeYap() menu 8000.75 &LaTeX.&PDFLaTeX,lp :call ExePDFLaTeX() menu 8000.80 &LaTeX.dvips :call Exedvips() menu 8000.81 &LaTeX.&dvips\ ps\ fonts,dv :call Exedvipsps() menu 8000.82 &LaTeX.LaTeX\ to\ Postscript,lf :call ExeTexifyPS() menu 8000.83 &LaTeX.LaTeX\ to\ Postscript\ Light,lg :call ExeTexifyPSLight() menu 8000.84 &LaTeX.&gsview :call Exegsv() menu 8000.85 &LaTeX.LaTeX\ to\ &HTML :call Exetohtml() menu 8000.90 &LaTeX.Projec&tname,pr :call GetProjName() endfunction :function! LatexUnMap() unmap ,la unmap ,vi unmap ,pr unmap ,lp unmap ,lb unmap ,dv unmap ,ls unmap ,lf unmap ,lg vunmap ,ren unmap ,en vunmap ,rcm unmap ,cm :endfunction :function! LatexMap() map ,la :call ExeLatex() map ,vi :call ExeYap() map ,pr :call GetProjName() map ,lb :call ExeBibtex() map ,lp :call ExePDFLaTeX() map ,dv :call Exedvipsps() map ,ls :call ExeTexify() map ,lf :call ExeTexifyPS() map ,lg :call ExeTexifyPSLight() vmap ,ren :call Plain_env() map ,en :call Empty_env() vmap ,rcm :call Plain_com() map ,cm :call Empty_com() :endfunction "-- moji dodaci! "======================================================================== " auctex src: " "-- auc-tex style mapings: sniped from auctex.vim " Greek letters, AucTex style bindings " No timeout. Applies to mappings such as `a for \alpha set notimeout :function! AuctexMap() inoremap inoremap a \alpha inoremap b \beta inoremap c \chi inoremap d \delta inoremap e \varepsilon inoremap f \varphi inoremap g \gamma inoremap h \eta inoremap i \int_{}^{}F}i " Or \iota or \infty or \in inoremap k \kappa inoremap l \lambda inoremap m \mu inoremap n \nu inoremap o \omega inoremap p \pi inoremap q \theta inoremap r \rho inoremap s \sigma inoremap t \tau inoremap u \upsilon inoremap v \vee inoremap w \wedge inoremap x \xi inoremap y \psi inoremap z \zeta inoremap D \Delta inoremap I \int_{}^{}F}i inoremap F \Phi inoremap G \Gamma inoremap L \Lambda inoremap N \nabla inoremap O \Omega inoremap Q \Theta inoremap R \varrho inoremap S \sum_{}^{}F}i inoremap U \Upsilon inoremap X \Xi inoremap Y \Psi inoremap 0 \emptyset inoremap 1 \left inoremap 2 \right inoremap 3 \Big inoremap 6 \partial inoremap 8 \infty inoremap / \frac{}{}F}i inoremap % \frac{}{}F}i inoremap @ \circ inoremap \| \Big\| inoremap = \equiv inoremap \ \setminus inoremap . \cdot inoremap * \times inoremap & \wedge inoremap - \bigcap inoremap + \bigcup inoremap ( \subset inoremap ) \supset inoremap < \leq inoremap > \geq inoremap , \nonumber inoremap : \dots inoremap ~ \tilde{} inoremap ^ \hat{} inoremap ; \dot{} inoremap _ \bar{} inoremap \cos inoremap \exp\left(\right)F(a inoremap \in inoremap \downarrow inoremap \log inoremap \uparrow inoremap \uparrow inoremap \downarrow inoremap \downarrow inoremap \to inoremap \lim_{} inoremap \sin inoremap \tan inoremap \ell inoremap \nonumber\\&& " Smart quotes. " Thanks to Ron Aaron . function! s:TexQuotes() let insert = "''" let left = getline('.')[col('.')-2] if left =~ '^\(\|\s\)$' let insert = '``' elseif left == '\' let insert = '"' endif return insert endfunction inoremap " =TexQuotes() " Typing ... results in \dots {{{ function! s:Dots() let left = strpart(getline('.'),col('.')-3,2) if left == '..' return "\\\\dots" else return '.' endif endfunction inoremap . =Dots() inoremap . " Typing __ results in _{} function! s:SubBracket() let insert = '_' let left = getline('.')[col('.')-2] if left == '_' let insert = "{}\" endif return insert endfunction inoremap _ =SubBracket() " Typing ^^ results in ^{} function! s:SuperBracket() let insert = '^' let left = getline('.')[col('.')-2] if left == '^' let insert = "{}\" endif return insert endfunction inoremap ^ =SuperBracket() " Bracket Completion Macros " Key Bindings " Typing the symbol a second time (for example, $$) will result in one " of the symbole (for instance, $). With {, typing \{ will result in \{\}. inoremap ( =Double('(',')') "inoremap [ =Double('[',']') inoremap [ =CompleteSlash('[',']') inoremap $ =Double('$','$') inoremap & =DoubleAmpersands() inoremap { =CompleteSlash('{','}') inoremap \| =CompleteSlash("\|","\|") " Functions " For () and $$ function! s:Double(left,right) if strpart(getline('.'),col('.')-2,2) == a:left . a:right return "\" else return a:left . a:right . "\" endif endfunction " Complete [, \[, {, \{, |, \| function! s:CompleteSlash(left,right) let column = col('.') let first = getline('.')[column-2] let second = getline('.')[column-1] if first == "\\" if a:left == '[' return "\[\\\\]\" else return a:left . "\\" . a:right . "\\" endif else if a:left =~ '\[\|{' \ && strpart(getline('.'),col('.')-2,2) == a:left . a:right return "\" else return a:left . a:right . "\" endif endif endfunction " Double ampersands, if you are in an eqnarray or eqnarray* environment. function! s:DoubleAmpersands() let stop = 0 let currentline = line('.') while stop == 0 let currentline = currentline - 1 let thisline = getline(currentline) if thisline =~ '\\begin' || currentline == 0 let stop = 1 endif endwhile if thisline =~ '\\begin{eqnarray\**}' return "&&\" elseif strpart(getline('.'),col('.')-2,2) == '&&' return "\" else return '&' endif endfunction " Personal or Temporary bindings. {{{ inoremap ;; ; inoremap ;e ~\eqref{} inoremap ;r ~\ref{} inoremap ;c ~\cite{} inoremap ;- \vec{} inoremap ;b {\bf } inoremap ;n \nomenclature[]{}{} "inoremap ;p p_0 "inoremap ; \bigskip\noindent\textbf{} "inoremap ;e E\left[\right]F\i "inoremap ;i \int_{\mathbf{R}^d} "inoremap ;I \int_{0}^{\infty} "inoremap ;p P\left(\right)F\i "inoremap ;1 \newline\noindent\textbf{} "inoremap ;s S_t^{\alpha} :endfunction set timeoutlen=2500 :au BufEnter *.tex,*.dtx,*.ltx,*.bib,*.sty :call LatexMenu() :au BufLeave *.tex,*.dtx,*.ltx,*.bib,*.sty :call LatexUnMenu() :au BufEnter *.tex,*.dtx,*.ltx,*.bib,*.sty :call LatexMap() :au BufLeave *.tex,*.dtx,*.ltx,*.bib,*.sty :call LatexUnMap() :au BufEnter *.tex,*.dtx,*.ltx,*.bib,*.sty :call AuctexMap() " :au BufEnter *.tex,*.dtx,*.ltx :call Standard_map() " :au BufLeave *.tex,*.dtx,*.ltx :call Remove_map() ":au BufEnter *.bib :call Bibtex_map() ":au BufLeave *.bib :call Remove_map() :au BufEnter *.tex,*.dtx,*.ltx :set isk+=58,46 :au BufLeave *.tex,*.dtx,*.ltx :set isk-=58,46