Update of /cvsroot/vim-latex/vimfiles/ftplugin/tex
In directory usw-pr-cvs1:/tmp/cvs-serv7759
Added Files:
Tag: release-nov-10-02-auctex-brach
ls_brackets.vim ls_formatline.vim
Log Message:
adding files from carl mueller
--- NEW FILE: ls_brackets.vim ---
" ==============================================================================
" Author: Carl Mueller
" (incorporated into latex-suite by Srinath Avadhanula)
" Last Change: Sun Nov 10 05:00 PM 2002 PST
" Desciption:
" ==============================================================================
" ==============================================================================
" Boldface: Mapping <M-b> to insert \mathbf{} {{{
" Insert Mode:
" Typing <M-b> after a character capitalizes it and encloses it in \mathbf{}
" Visual Mode:
" Encloses the selected portion in \mathbf{}
inoremap <buffer> <M-b> <Left>\mathbf{<Right>}<Esc>hvUla
vnoremap <buffer> <M-b> <C-C>`>a}<Esc>`<i\mathbf{<Esc>
" }}}
" ==============================================================================
" MathCal: Mapping <M-c> to insert \mathcal{} or \cite{} {{{
" Insert Mode:
" 1. If the previous character is a letter or number, then capitalize it and
" enclose it in \mathcal{}
" 2. otherwise insert \cite{«»}«»
" Visual Mode:
" 1. Enclose selection in \mathcal{}
inoremap <buffer> <M-c> <C-R>=<SID>MathCal()<CR>
function! s:MathCal()
let line = getline(line("."))
let char = line[col(".")-2]
if char =~ '[a-zA-Z0-9]'
return "\<BS>".'\mathcal{'.toupper(char).'}'
else
return IMAP_PutTextWithMovement('\cite{«»}«»')
endif
endfunction
vnoremap <buffer> <M-c> <C-C>`>a}<Esc>`<i\mathcal{<Esc>
" }}}
" ==============================================================================
" LeftRight: Function for inserting \left and \right in front of bracket chars
" in various ways using <M-l>. If not possible, insert \label{«»}«»
" {{{
"
inoremap <buffer> <M-l> <C-r>=<SID>LeftRight()<CR>
noremap <buffer> <M-l> :call <SID>PutLeftRight()<CR>
" LeftRight: maps <M-l> in insert mode. {{{
" This is a polymorphic function, which maps the behaviour of <M-l> in the
" following way:
" If the character before typing <M-l> is one of '([{|<q', then do the
" following:
" 1. (<M-l> \left(«»\right«»
" similarly for [, |
" {<M-l> \left\{«»\right\}«»
" 2. <<M-l> \langle«»\rangle«»
" 3. q<M-l> \lefteqn{«»}«»
" otherwise insert \label{«»}«»
function! s:LeftRight()
let line = getline(line("."))
let char = line[col(".")-2]
let previous = line[col(".")-3]
let matchedbrackets = '()[]{}||'
if char =~ '(\|\[\|{\||'
let add = ''
if char =~ '{'
let add = "\\"
endif
let rhs = matchstr(matchedbrackets, char.'\zs.\ze')
return "\<BS>".IMAP_PutTextWithMovement('\left'.add.char.'«»\right'.add.rhs.'«»')
elseif char == '<'
return "\<BS>".IMAP_PutTextWithMovement('langle«»\rangle«»')
elseif char == 'q'
return "\<BS>".IMAP_PutTextWithMovement('\lefteqn{«»}«»')
else
return '\label{«»}«»'
endif
endfunction " }}}
" PutLeftRight: maps <M-l> in normal mode {{{
" Put \left...\right in front of the matched brackets.
function! s:PutLeftRight()
let previous = getline(line("."))[col(".") - 2]
let char = getline(line("."))[col(".") - 1]
if previous == '\'
if char == '{'
exe "normal ileft\\\<Esc>l%iright\\\<Esc>l%"
elseif char == '}'
exe "normal iright\\\<Esc>l%ileft\\\<Esc>l%"
endif
elseif char =~ '\[\|('
exe "normal i\\left\<Esc>l%i\\right\<Esc>l%"
elseif char =~ '\]\|)'
exe "normal i\\right\<Esc>l%i\\left\<Esc>l%"
endif
endfunction " }}}
" }}}
" ==============================================================================
" vim:fdm=marker
--- NEW FILE: ls_formatline.vim ---
" ==============================================================================
" Author: Carl Mueller
" (incorporated into latex-suite by Srinath Avadhanula)
" Last Change: Sun Nov 10 05:00 PM 2002 PST
" Desciption:
" ==============================================================================
if &tw > 0
let b:tw = &tw
else
let b:tw = 79
endif
" The following is necessary for TexFormatLine() and TexFill()
set tw=0
" With this map, <Space> will split up a long line, keeping the dollar
" signs together (see the next function, TexFormatLine).
inoremap <buffer> <Space> <Space><Esc>:call <SID>TexFill(b:tw)<CR>a
function! s:TexFill(width)
if col(".") > a:width
exe "normal! a##\<Esc>"
call <SID>TexFormatLine(a:width)
exe "normal! ?##\<CR>2s\<Esc>"
endif
endfunction
function! s:TexFormatLine(width)
let first = strpart(getline(line(".")),0,1)
normal! $
let length = col(".")
let go = 1
while length > a:width+2 && go
let between = 0
let string = strpart(getline(line(".")),0,a:width)
" Count the dollar signs
let number_of_dollars = 0
let evendollars = 1
let counter = 0
while counter <= a:width-1
if string[counter] == '$' && string[counter-1] != '\' " Skip \$.
let evendollars = 1 - evendollars
let number_of_dollars = number_of_dollars + 1
endif
let counter = counter + 1
endwhile
" Get ready to split the line.
exe "normal! " . (a:width + 1) . "|"
if evendollars
" Then you are not between dollars.
exe "normal! ?\\$\\| \<CR>W"
else
" Then you are between dollars.
normal! F$
if col(".") == 1 || strpart(getline(line(".")),col(".")-1,1) != "$"
let go = 0
endif
endif
if first == '$' && number_of_dollars == 1
let go = 0
else
exe "normal! i\<CR>\<Esc>$"
let first = strpart(getline(line(".")),0,1)
endif
let length = col(".")
endwhile
endfunction
|