[Vim-latex-devel] entering your own environments
Brought to you by:
srinathava,
tmaas
From: Carl M. <cm...@ma...> - 2002-11-12 17:12:49
|
Am I missing something? I don't see how to enter a user-defined environment. For instance, users always have commands like \newtheorem{lemma}{Lemma} so there should be a way of entering a generic or user-defined environment. Here was how I did it, in auctex.vim. Best wishes, Carl ----------------------------------- " The next idea came from a contributed NEdit macro. " typing the name of the environment followed by <F5> results in " \begin{environment} \end{environment} " But, typing <F5> at the beginning of the line results in a prompt " for the name of the environment. inoremap <buffer> <F5> <Esc>:call <SID>DoEnvironment()<CR> function! s:DoEnvironment() let l = getline(line(".")) let env = strpart(l, 0, col(".")) if env =~ '^\s*$' call <SID>PutEnvironment(l, input("Environment? ")) else normal 0D call <SID>SetEnvironment(env) endif startinsert endfunction function! s:PutEnvironment(indent, env) put! =a:indent . '\begin{' . a:env . '}' +put =a:indent . '\end{' . a:env . '}' normal k$ if a:env=="array" call <SID>ArgumentsForArray(input("{rlc}? ")) elseif a:env =~# '^\(theorem\|lemma\|equation\|eqnarray\|align\|multline\)$' exe "normal O\\label\<C-V>{" . input("Label? ") . "}\<Esc>j" endif endfunction |