[Vim-latex-cvs] vimfiles/ftplugin/latex-suite main.vim,1.7,1.8
Brought to you by:
srinathava,
tmaas
From: <sri...@us...> - 2002-11-17 03:38:08
|
Update of /cvsroot/vim-latex/vimfiles/ftplugin/latex-suite In directory usw-pr-cvs1:/tmp/cvs-serv10862 Modified Files: main.vim Log Message: . added the function TexFormatLine and TexFill from Carl Mueller. These functions map the <space> key in a way that $'s are not split across lines. Index: main.vim =================================================================== RCS file: /cvsroot/vim-latex/vimfiles/ftplugin/latex-suite/main.vim,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** main.vim 12 Nov 2002 18:54:53 -0000 1.7 --- main.vim 17 Nov 2002 03:38:00 -0000 1.8 *************** *** 4,8 **** " Email: sr...@fa... " URL: ! " Last Change: Mon Nov 11 09:00 PM 2002 PST " " Help: --- 4,8 ---- " Email: sr...@fa... " URL: ! " Last Change: Sat Nov 16 06:00 PM 2002 PST " " Help: *************** *** 316,319 **** --- 316,371 ---- endif endfunction " }}} + " TexFormatLine: format line retaining $$'s on the same line. {{{ + 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 + " }}} + " }}} " ============================================================================== *************** *** 449,452 **** --- 501,514 ---- inoremap <buffer> <silent> <BS> <C-R>=<SID>SmartBS(<SID>SmartBS_pat())<CR> inoremap <buffer> <silent> . <C-R>=<SID>SmartDots()<CR> + " for FormatLine {{{ + if &l:tw > 0 + let b:tw = &l:tw + else + let b:tw = 79 + endif + " The following is necessary for TexFormatLine() and TexFill() + setlocal tw=0 + inoremap <buffer> <silent> <Space> <Space><Esc>:call <SID>TexFill(b:tw)<CR>a + " }}} " viewing/searching if !hasmapto('RunLaTeX') |