[Vim-latex-cvs] vimfiles/ftplugin/latex-suite envmacros.vim,1.5,1.6
Brought to you by:
srinathava,
tmaas
From: <mi...@us...> - 2002-11-15 22:30:19
|
Update of /cvsroot/vim-latex/vimfiles/ftplugin/latex-suite In directory usw-pr-cvs1:/tmp/cvs-serv29927 Modified Files: envmacros.vim Log Message: - replaced "" with '' wherever it was possible. Vim parses each "" looking for special chars, reducing number of these even if this is worth only 1/1000s (or less) per "" can be worth over 1s for whole lS. And 1s is looong for Vim users :) If you agree I will do it for all files. - Removed bugs mentioned by Srinatha: wrong detection of environment with <S-F5> and inserting second label. Could you describe more bugs? - <F5> in now "intelligent". It can recognize if it is in preamble or body of the document. If in preamble takes line as an argument or asks for it and inserts \usepackage{argument} line. If package is supported makes appropriate corrections. If in body similar actions ar taken with environment. - removed function s:ChangeEnvironment and shortcuts as redundant Index: envmacros.vim =================================================================== RCS file: /cvsroot/vim-latex/vimfiles/ftplugin/latex-suite/envmacros.vim,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** envmacros.vim 14 Nov 2002 23:02:53 -0000 1.5 --- envmacros.vim 15 Nov 2002 22:30:16 -0000 1.6 *************** *** 3,7 **** " Author: Mikolaj Machowski " Created: Tue Apr 23 08:00 PM 2002 PST ! " Last Change: pi± lis 15 12:00 2002 C " " Description: mappings/menus for environments. --- 3,7 ---- " Author: Mikolaj Machowski " Created: Tue Apr 23 08:00 PM 2002 PST ! " Last Change: pi± lis 15 11:00 2002 C " " Description: mappings/menus for environments. *************** *** 59,63 **** if g:Tex_EnvironmentMaps && !exists('s:doneOnce') ! call IMAP (a:lhs, "\\begin{".a:name."}\<CR>".extra."«»\<CR>\\end{".a:name."}«»", 'tex') exec 'vnoremap <silent> '.vlhs.' '.vrhs endif --- 59,63 ---- if g:Tex_EnvironmentMaps && !exists('s:doneOnce') ! call IMAP (a:lhs, '\begin{'.a:name."}\<CR>".extra."«»\<CR>\\end{".a:name."}«»", 'tex') exec 'vnoremap <silent> '.vlhs.' '.vrhs endif *************** *** 123,127 **** if g:Tex_SectionMaps && !exists('s:doneOnce') exe 'vnoremap '.vlhs.' '.vrhs ! call IMAP (a:lhs, "\\".a:name."{«»}«»", 'tex') endif --- 123,127 ---- if g:Tex_SectionMaps && !exists('s:doneOnce') exe 'vnoremap '.vlhs.' '.vrhs ! call IMAP (a:lhs, "\\".a:name.'{«»}«»', 'tex') endif *************** *** 135,142 **** let advvrhs = "\<C-\\>\<C-N>:call Tex_VisSecAdv('".a:name."')\<CR>" ! exe 'amenu '.advlocation." <plug>".advirhs exe 'vnoremenu '.advlocation." ".advvrhs ! exe 'amenu '.location." <plug>".irhs exe 'vnoremenu '.location." ".vrhs endif --- 135,142 ---- let advvrhs = "\<C-\\>\<C-N>:call Tex_VisSecAdv('".a:name."')\<CR>" ! exe 'amenu '.advlocation.' <plug>'.advirhs exe 'vnoremenu '.advlocation." ".advvrhs ! exe 'amenu '.location.' <plug>'.irhs exe 'vnoremenu '.location." ".vrhs endif *************** *** 191,195 **** " }}} " Lists {{{ ! call s:Tex_SpecialMacros("ELI", '&Lists.', 'list', "\\begin{list}{«label»}{«commands»}\<cr>\\item «»\<cr>\\end{list}«»") call s:Tex_EnvMacros('EEN', '&Lists.', 'enumerate') call s:Tex_EnvMacros('EIT', '&Lists.', 'itemize') --- 191,195 ---- " }}} " Lists {{{ ! call s:Tex_SpecialMacros('ELI', '&Lists.', 'list', "\\begin{list}{«label»}{«commands»}\<cr>\\item «»\<cr>\\end{list}«»") call s:Tex_EnvMacros('EEN', '&Lists.', 'enumerate') call s:Tex_EnvMacros('EIT', '&Lists.', 'itemize') *************** *** 198,202 **** " }}} " Tables {{{ ! call s:Tex_SpecialMacros("ETE", '&Tables.', 'table', "\\begin{table}\<cr>\\centering\<cr>\\caption{tab:ä}\<cr>\\begin{tabular}{«dimensions»}\<cr>«»\<cr>\\end{tabular}\<cr>\\label{tab:«label»}\<cr>\\end{table}«»") call s:Tex_EnvMacros('ETG', '&Tables.', 'tabbing') call s:Tex_EnvMacros('', '&Tables.', 'table*') --- 198,202 ---- " }}} " Tables {{{ ! call s:Tex_SpecialMacros('ETE', '&Tables.', 'table', "\\begin{table}\<cr>\\centering\<cr>\\caption{tab:ä}\<cr>\\begin{tabular}{«dimensions»}\<cr>«»\<cr>\\end{tabular}\<cr>\\label{tab:«label»}\<cr>\\end{table}«»") call s:Tex_EnvMacros('ETG', '&Tables.', 'tabbing') call s:Tex_EnvMacros('', '&Tables.', 'table*') *************** *** 214,218 **** " }}} " Structure {{{ ! call s:Tex_SpecialMacros("EAR", 'Math.', 'array', "\\leftä\<cr>\\begin{array}{«dimension»}\<cr>«elements»\<cr>\\end{array}\<cr>\\right«»") call s:Tex_EnvMacros('EAB', '&Structure.', 'abstract') call s:Tex_EnvMacros('EAP', '&Structure.', 'appendix') --- 214,218 ---- " }}} " Structure {{{ ! call s:Tex_SpecialMacros('EAR', 'Math.', 'array', "\\leftä\<cr>\\begin{array}{«dimension»}\<cr>«elements»\<cr>\\end{array}\<cr>\\right«»") call s:Tex_EnvMacros('EAB', '&Structure.', 'abstract') call s:Tex_EnvMacros('EAP', '&Structure.', 'appendix') *************** *** 248,260 **** " Miscellaneous {{{ call s:Tex_SpecialMacros('', '', '-sepenv1-', ' :', 0) ! call s:Tex_SpecialMacros("EFI", '', 'figure', "\\begin{figure}[«htpb»]\<cr>\\centerline{\\psfig{figure=«eps file»}}\<cr>\\caption{«caption text»}\<cr>\\label{fig:«label»}\<cr>\\end{figure}«»") call s:Tex_EnvMacros('', '', 'figure*') call s:Tex_EnvMacros('ELR', '', 'lrbox') ! call s:Tex_SpecialMacros("EMP", '', 'minipage', "\\begin{minipage}[«tb»]{«width»}\<cr>«»\<cr>\\end{minipage}«»") ! call s:Tex_SpecialMacros("EPI", '', 'picture', "\\begin{picture}(«width», «height»)(«xoff»,«yoff»)\<cr>\\put(«xoff»,«yoff»){\\framebox(«»,«»){«»}}\<cr>\\end{picture}«»") " }}} if g:Tex_CatchVisMapErrors ! exe "vnoremap ".g:Tex_Leader2." :\<C-u>call ExecMap('".g:Tex_Leader2."', 'v')\<CR>" endif --- 248,260 ---- " Miscellaneous {{{ call s:Tex_SpecialMacros('', '', '-sepenv1-', ' :', 0) ! call s:Tex_SpecialMacros('EFI', '', 'figure', "\\begin{figure}[«htpb»]\<cr>\\centerline{\\psfig{figure=«eps file»}}\<cr>\\caption{«caption text»}\<cr>\\label{fig:«label»}\<cr>\\end{figure}«»") call s:Tex_EnvMacros('', '', 'figure*') call s:Tex_EnvMacros('ELR', '', 'lrbox') ! call s:Tex_SpecialMacros('EMP', '', 'minipage', "\\begin{minipage}[«tb»]{«width»}\<cr>«»\<cr>\\end{minipage}«»") ! call s:Tex_SpecialMacros('EPI', '', 'picture', "\\begin{picture}(«width», «height»)(«xoff»,«yoff»)\<cr>\\put(«xoff»,«yoff»){\\framebox(«»,«»){«»}}\<cr>\\end{picture}«»") " }}} if g:Tex_CatchVisMapErrors ! exe 'vnoremap '.g:Tex_Leader2." :\<C-u>call ExecMap('".g:Tex_Leader2."', 'v')\<CR>" endif *************** *** 264,274 **** " Tex_itemize: {{{ function! Tex_itemize(indent, env) ! exe 'normal i'.a:indent."\\begin{".a:env."}\<cr>\\item \<cr>\\end{".a:env."}«»\<Up>" endfunction " }}} " Tex_description: {{{ function! Tex_description(indent, env) ! let itlabel = input("(Optional) Item label? ") ! if (itlabel != "") let itlabel = '['.itlabel.']' endif --- 264,274 ---- " Tex_itemize: {{{ function! Tex_itemize(indent, env) ! exe 'normal i'.a:indent.'\begin{'.a:env."}\<cr>\\item \<cr>\\end{".a:env."}«»\<Up>" endfunction " }}} " Tex_description: {{{ function! Tex_description(indent, env) ! let itlabel = input('(Optional) Item label? ') ! if itlabel != '' let itlabel = '['.itlabel.']' endif *************** *** 278,304 **** " Tex_figure: {{{ function! Tex_figure(indent, env) ! let flto = input("Float to (htbp)? ") ! let caption = input("Caption? ") ! let center = input("Center ([y]/n)? ") 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? ") ! if (flto != "") ! let flto = "[".flto."]\<cr>" else let flto = "\<cr>" endif ! if (pic != "") ! let pic = "\\input{".pic."}\<cr>" else let pic = "ä\<cr>" endif ! if (caption != "") ! let caption = "\\caption{".caption."}\<cr>" endif ! if (label != "") ! let label = "\\label{fig:".label."}\<cr>" endif ! if (center == "y" || center == "") let centr = "\\begin{center}\<cr>" let centr = centr . pic --- 278,304 ---- " Tex_figure: {{{ function! Tex_figure(indent, env) ! let flto = input('Float to (htbp)? ') ! let caption = input('Caption? ') ! let center = input('Center ([y]/n)? ') 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? ') ! if flto != '' ! let flto = '['.flto."]\<cr>" else let flto = "\<cr>" endif ! if pic != '' ! let pic = '\input{'.pic."}\<cr>" else let pic = "ä\<cr>" endif ! if caption != '' ! let caption = '\caption{'.caption."}\<cr>" endif ! if label != '' ! let label = '\label{fig:'.label."}\<cr>" endif ! if (center == 'y' || center == '') let centr = "\\begin{center}\<cr>" let centr = centr . pic *************** *** 311,317 **** let centr = centr . label endif ! let figure = "\\begin{".a:env."}".flto let figure = figure . centr ! let figure = figure . "\\end{".a:env."}" exe 'normal i'.a:indent.figure."\<Esc>$" endfunction --- 311,317 ---- let centr = centr . label endif ! let figure = '\begin{'.a:env.'}'.flto let figure = figure . centr ! let figure = figure . '\end{'.a:env.'}' exe 'normal i'.a:indent.figure."\<Esc>$" endfunction *************** *** 323,327 **** let center = input('Center (y/n)? ') let label = input('Label? ') ! if (flto != "") let flto ='['.flto."]\<cr>" else --- 323,327 ---- let center = input('Center (y/n)? ') let label = input('Label? ') ! if flto != '' let flto ='['.flto."]\<cr>" else *************** *** 329,339 **** endif let ret='\begin{table}'.flto ! if (center == "y") let ret=ret."\\begin{center}\<cr>" endif ! let foo = "\\begin{tabular}" let pos = input('(Optional) Position (t b)? ') ! if (pos!='') ! let foo = foo.'['.pos."]" else let foo = foo."\<cr>" --- 329,339 ---- endif let ret='\begin{table}'.flto ! if center == 'y' let ret=ret."\\begin{center}\<cr>" endif ! let foo = '\begin{tabular}' let pos = input('(Optional) Position (t b)? ') ! if pos != '' ! let foo = foo.'['.pos.']' else let foo = foo."\<cr>" *************** *** 344,365 **** endif let ret = ret.foo.'{'.format."}\<cr>ä\<cr>\\end{tabular}«»\<cr>" ! if (center == 'y') let ret=ret."\\end{center}\<cr>" endif ! if (caption != '') let ret=ret.'\caption{'.caption."}\<cr>" endif ! if (label != "") let ret=ret.'\label{tab:'.label."}\<cr>" endif ! let ret=ret."\\end{table}«»" ! exe "normal i".ret."\<Esc>?ä\<cr>:nohl\<cr>C" endfunction " }}} " Tex_tabular: {{{ function! Tex_tabular(indent, env) ! let pos = input("(Optional) Position (t b)? ") let format = input("Format ( l r c p{width} | @{text} )? ") ! if (pos != '') let pos = '['.pos.']' endif --- 344,365 ---- endif let ret = ret.foo.'{'.format."}\<cr>ä\<cr>\\end{tabular}«»\<cr>" ! if center == 'y' let ret=ret."\\end{center}\<cr>" endif ! if caption != '' let ret=ret.'\caption{'.caption."}\<cr>" endif ! if label != '' let ret=ret.'\label{tab:'.label."}\<cr>" endif ! let ret=ret.'\end{table}«»' ! exe 'normal i'.ret."\<Esc>?ä\<cr>:nohl\<cr>C" endfunction " }}} " Tex_tabular: {{{ function! Tex_tabular(indent, env) ! let pos = input('(Optional) Position (t b)? ') let format = input("Format ( l r c p{width} | @{text} )? ") ! if pos != '' let pos = '['.pos.']' endif *************** *** 367,382 **** let format = '{'.format.'}' endif ! exe 'normal i'.a:indent."\\begin{".a:env.'}'.pos.format."\<cr> \<cr>\\end{".a:env."}«»\<Up>" endfunction " }}} " Tex_eqnarray: {{{ function! Tex_eqnarray(indent, env) ! let label = input("Label? ") ! if (label != "") let arrlabel = '\label{'.label."}\<cr> " else ! let arrlabel = " " endif ! exe 'normal i'.a:indent."\\begin{".a:env."}\<cr>".arrlabel."\<cr>\\end{".a:env."}«»\<Up>" endfunction " }}} --- 367,382 ---- let format = '{'.format.'}' endif ! exe 'normal i'.a:indent.'\begin{'.a:env.'}'.pos.format."\<cr> \<cr>\\end{".a:env."}«»\<Up>" endfunction " }}} " Tex_eqnarray: {{{ function! Tex_eqnarray(indent, env) ! let label = input('Label? ') ! if label != '' let arrlabel = '\label{'.label."}\<cr> " else ! let arrlabel = ' ' endif ! exe 'normal i'.a:indent.'\begin{'.a:env."}\<cr>".arrlabel."\<cr>\\end{".a:env."}«»\<Up>" endfunction " }}} *************** *** 384,391 **** function! Tex_list(indent, env) let label = input('Label (for \item)? ') ! if (label != '') let label = '{'.label.'}' let addcmd = input('Additional commands? ') ! if (addcmd != '') let label = label . '{'.addcmd.'}' endif --- 384,391 ---- function! Tex_list(indent, env) let label = input('Label (for \item)? ') ! if label != '' let label = '{'.label.'}' let addcmd = input('Additional commands? ') ! if addcmd != '' let label = label . '{'.addcmd.'}' endif *************** *** 393,397 **** let label = '' endif ! exe 'normal i'.a:indent."\\begin{list}".label."\<cr>\\item \<cr>\\end{list}«»\<Up>" endfunction " }}} --- 393,397 ---- let label = '' endif ! exe 'normal i'.a:indent.'\begin{list}'.label."\<cr>\\item \<cr>\\end{list}«»\<Up>" endfunction " }}} *************** *** 401,405 **** let opts = input('(Optional) Options? ') let foo = '\documentclass' ! if (opts == '') let foo = foo.'{'.dstyle.'}' else --- 401,405 ---- let opts = input('(Optional) Options? ') let foo = '\documentclass' ! if opts == '' let foo = foo.'{'.dstyle.'}' else *************** *** 414,418 **** let pos = input('(Optional) Position (t b)? ') let width = input('Width? ') ! if (pos=="") let foo = foo.'{'.width.'}' else --- 414,418 ---- let pos = input('(Optional) Position (t b)? ') let width = input('Width? ') ! if pos == '' let foo = foo.'{'.width.'}' else *************** *** 428,434 **** let foo = '{'.indent.'}' let biblabel = input('(Optional) Bibitem label? ') ! let key = input("Add key? ") let bar = '\bibitem' ! if (biblabel != '') let bar = bar.'['.biblabel.']' endif --- 428,434 ---- let foo = '{'.indent.'}' let biblabel = input('(Optional) Bibitem label? ') ! let key = input('Add key? ') let bar = '\bibitem' ! if biblabel != '' let bar = bar.'['.biblabel.']' endif *************** *** 441,453 **** " asdf is a fake argument to recognize if call is coming from keyboard or from " menu ! inoremap <buffer> <F5> <C-0>:call Tex_DoEnvironment("asdf")<CR> ! noremap <buffer> <F5> :call Tex_DoEnvironment("asdf")<CR> function! Tex_DoEnvironment(env) " {{{ ! let l = getline(".") ! if a:env == "asdf" let env = matchstr(l, '^\s*\zs.*') if env == '' ! call Tex_PutEnvironment(l, input("Environment? ")) else let ind = matchstr(l, '^\s*\ze') --- 441,492 ---- " asdf is a fake argument to recognize if call is coming from keyboard or from " menu ! inoremap <F5> <C-O>:call Tex_FFive_intelligent()<cr> ! noremap <F5> :call Tex_FFive_intelligent()<cr> ! function! Tex_FFive_intelligent() " {{{ ! let start_line = line('.') ! let pos = line('.').' | normal! '.virtcol('.').'|' ! if search('\\documentclass', 'bW') && search('\\begin{document}') ! let begin_line = search('\\begin{document}') ! if start_line < begin_line ! exe pos ! call Tex_package_from_line() ! else ! exe pos ! call Tex_DoEnvironment('asdf') ! endif ! elseif search('\\documentclass') ! exe pos ! call Tex_package_from_line() ! else ! exe pos ! call Tex_DoEnvironment('asdf') ! endif ! endfunction " }}} ! function! Tex_package_from_line() " {{{ ! " Function Tex_PutPackage is defined in packages.vim ! let l = getline(".") ! let pack = matchstr(l, '^\s*\zs.*') ! if pack == '' ! let pack = input('Package? ') ! if pack != '' ! call Tex_PutPackage(pack) ! endif ! return 0 ! else ! normal 0D ! call Tex_PutPackage(pack) ! endif ! endfunction " }}} ! function! Tex_DoEnvironment(env) " {{{ ! let l = getline('.') ! if a:env == 'asdf' let env = matchstr(l, '^\s*\zs.*') if env == '' ! let env = input('Environment? ') ! if env != '' ! call Tex_PutEnvironment(l, env) ! endif else let ind = matchstr(l, '^\s*\ze') *************** *** 469,474 **** elseif a:env =~ "tabular\\|tabular*\\|array\\|array*" call Tex_tabular(a:indent, a:env) ! elseif exists("*Tex_".a:env) ! exe "call Tex_".a:env."(a:indent, a:env)" else exe 'normal i'.a:indent.'\begin{'.a:env."}\<cr> \<cr>\\end{".a:env."}«»\<Up>" --- 508,513 ---- elseif a:env =~ "tabular\\|tabular*\\|array\\|array*" call Tex_tabular(a:indent, a:env) ! elseif exists('*Tex_'.a:env) ! exe 'call Tex_'.a:env.'(a:indent, a:env)' else exe 'normal i'.a:indent.'\begin{'.a:env."}\<cr> \<cr>\\end{".a:env."}«»\<Up>" *************** *** 478,488 **** let b:DoubleDollars = 0 - inoremap <buffer> <C-F5> <C-O>:call <SID>ChangeEnvironment(input("Environment? "))<CR> - noremap <buffer> <C-F5> :call <SID>ChangeEnvironment(input("Environment? "))<CR> inoremap <buffer> <S-F5> <C-O>:call Tex_change_environment()<CR> ! noremap <buffer> <S-F5> :call Tex_change_environment()<CR> function! Tex_AmsLatex() " {{{ ! if g:Tex_package_supported =~ "amsmath" let amslatex = 1 endif --- 517,525 ---- let b:DoubleDollars = 0 inoremap <buffer> <S-F5> <C-O>:call Tex_change_environment()<CR> ! noremap <buffer> <S-F5> :call Tex_change_environment()<CR> function! Tex_AmsLatex() " {{{ ! if g:Tex_package_supported =~ 'amsmath' let amslatex = 1 endif *************** *** 494,506 **** let s:item_environment = 'list,trivlist,enumerate,itemize,theindex' function Tex_change_environment() " {{{ ! let env_line = searchpair("\\[\\|begin{", "", "\\]\\|end{", "bn") if env_line != 0 ! if getline(env_line) =~ "\\[" ! let env_name = "[" else let env_name = matchstr(getline(env_line), 'begin{\zs.\{-}\ze}') endif endif ! if !exists("env_name") echomsg "You are not inside environment" return 0 --- 531,543 ---- let s:item_environment = 'list,trivlist,enumerate,itemize,theindex' function Tex_change_environment() " {{{ ! let env_line = searchpair("\\[\\|begin{", '', "\\]\\|end{", "bn") if env_line != 0 ! if getline(env_line) !~ 'begin{' ! let env_name = '[' else let env_name = matchstr(getline(env_line), 'begin{\zs.\{-}\ze}') endif endif ! if !exists('env_name') echomsg "You are not inside environment" return 0 *************** *** 512,516 **** \ "(3) align (4) align*\n". \ "(5) equation* (6) other\n". ! \ "(7) leave unchanged\n". \ "Enter number: ')" if change_env == 1 --- 549,553 ---- \ "(3) align (4) align*\n". \ "(5) equation* (6) other\n". ! \ "<cr> leave unchanged\n". \ "Enter number: ')" if change_env == 1 *************** *** 525,533 **** call <SID>Change('equation*', 0, '&\|\\lefteqn{\|\\nonumber\|\\\\', 0) elseif change_env == 6 ! call <SID>Change(input('Environment? '), 0, '', '') ! elseif change_env == 7 return 0 else ! echomsg "Wrong argument" return 0 endif --- 562,574 ---- call <SID>Change('equation*', 0, '&\|\\lefteqn{\|\\nonumber\|\\\\', 0) elseif change_env == 6 ! let env = input('Environment? ') ! if env != '' ! call <SID>Change(env, 0, '', '') ! endif ! return 0 ! elseif change_env == '' return 0 else ! echomsg 'Wrong argument' return 0 endif *************** *** 574,578 **** exe top call search('\\end\|\\\\') ! if line(".") != bottom exe '.+1,' . bottom . 's/\\\\/\\nonumber\\\\/e' exe (bottom-1) . 's/\s*$/ \\nonumber/' --- 615,619 ---- exe top call search('\\end\|\\\\') ! if line('.') != bottom exe '.+1,' . bottom . 's/\\\\/\\nonumber\\\\/e' exe (bottom-1) . 's/\s*$/ \\nonumber/' *************** *** 581,585 **** if a:label == 1 exe top ! if getline(top+1) !~ '.*label.*' let local_label = input('Label? ') if local_label != '' --- 622,627 ---- if a:label == 1 exe top ! if search("\\label", "W") > bottom ! exe top let local_label = input('Label? ') if local_label != '' *************** *** 591,595 **** exe 'silent '.top . ',' . bottom . ' g/\\label/delete' endif ! if exists("local_label") && local_label != '' exe start_line + 1.' | normal! '.start_col.'|' else --- 633,637 ---- exe 'silent '.top . ',' . bottom . ' g/\\label/delete' endif ! if exists('local_label') && local_label != '' exe start_line + 1.' | normal! '.start_col.'|' else *************** *** 604,642 **** endfunction " }}} - function! s:ChangeEnvironment(env) " {{{ - if b:DoubleDollars == 0 - call searchpair('\\\[\|\\begin{','','\\\]\|\\end{','') - else - call search('\$\$\|\\end{') - end - let l = getline(line(".")) - let indent = strpart(l, 0, match(l, '\S')) - if b:DoubleDollars == 0 - s/\\\]\|\\end{.\{-}}/\='\\end{' . a:env . '}'/ - call searchpair('\\\[\|\\begin{','','\\\]\|\\end{','b') - s/\\\[\|\\begin{.\{-}}/\='\\begin{' . a:env . '}'/ - else - s/\$\$\|\\end{.\{-}}/\='\\end{' . a:env . '}'/ - call search('\$\$\|\\begin{','b') - s/\$\$\|\\begin{.\{-}}/\='\\begin{' . a:env . '}'/ - endif - if a:env =~# '^\(theorem\|lemma\|equation\|eqnarray\|align\|multline\)$' - if (-1 == match(getline(line(".")),"\\label")) - let label = input("Label? ") - if label != '' - put! = indent . '\label{' . label . '}' - endif - endif - elseif a:env[strlen(a:env)-1] == '*' - if (-1 != match(getline(line(".")),"\\label")) - delete - endif - endif - echo '' - endfunction - " }}} function! s:PutInNonumber() " {{{ call search('\\end\|\\\\') ! if getline(line("."))[col(".")] != "e" .+1,'>s/\\\\/\\nonumber\\\\/e normal `>k --- 646,652 ---- endfunction " }}} function! s:PutInNonumber() " {{{ call search('\\end\|\\\\') ! if getline(line('.'))[col('.')] != "e" .+1,'>s/\\\\/\\nonumber\\\\/e normal `>k *************** *** 650,651 **** --- 660,662 ---- " vim:fdm=marker:nowrap:noet + |