Files
dotfiles/ftplugin/tex.vim
murgi 068d708cf2 Squashed 'vim/' content from commit bb3025e
git-subtree-dir: vim
git-subtree-split: bb3025e5a5f91efe7cee8a6b44c34a8d945956e3
2017-04-12 10:07:28 +02:00

30 lines
772 B
VimL

set formatoptions+=1rnmBa
" Reformat lines (getting the spacing correct) {{{
fun! TeX_fmt()
if (getline(".") != "")
let save_cursor = getpos(".")
let op_wrapscan = &wrapscan
set nowrapscan
let par_begin = '^\(%D\)\=\s*\($\|\\begin\|\\end\|\\\[\|\\\]\|\\\(sub\)*section\>\|\\item\>\|\\NC\>\|\\blank\>\|\\noindent\>\)'
let par_end = '^\(%D\)\=\s*\($\|\\start\|\\stop\|\\Start\|\\place\|\\\(sub\)*section\>\|\\item\>\|\\NC\>\|\\blank\>\)'
try
exe '?'.par_begin.'?+'
catch /E384/
1
endtry
norm V
try
exe '/'.par_end.'/-'
catch /E385/
$
endtry
norm gq
let &wrapscan = op_wrapscan
call setpos('.', save_cursor)
endif
endfun
nmap Q :call TeX_fmt()<CR>
" }}}