Several more updates:
http://pastebin.com/f24e40568
This version should work within comments as well, and it should not
cause a block to cross from comment to non-comment (so you don't
accidentally comment out good content with gwlp).
It's best to access from the link above, but I'll paste here too:
====
" Section: Paragraph formatting (autofill) {{{
" Correctly format paragraphs in LaTeX.
function! g:Tex_SelectParagraph ()
" TeX and LaTeX blocks common to both start and beginning of lp blocks
let l:tex_search =
"\\\\\\(begin\\|end\\|label\\|item\\|\\(new\\|renew\\|provide\\)\\(command\\|environment\\)\\|\\(new\\|set\\)\\(length\\|counter\\)\\|\\(def\\|let\\)[^\\w\\d]\\)"
" 0.) Move to beginning of line to prevent selecting the NEXT line
" THIS line is the one we want
exec "normal 0"
" 1.) Search UPWARDS for the start of a block and go one line DOWN
exec "normal ?" . l:tex_search .
"\\|^$\\|\\%^\\|.*\\S\\+.*\\\\\\@<!%\\|^\\s*%.*\\n\\(\\s*[^%]\\+\\)\...@=\\|\\(^\\s*%.*\\)\\@<!\\n\\s*%.*"
. "?1\<cr>"
" 2.) Move into visual mode
exec "normal v"
" 3.) Search DOWNWARDS for the end of a block and go one line UP
exec "normal /" . l:tex_search .
"\\|^$\\|\\%$\\|.*\\S\\+.*\\\\\\@<!%\\|\\(^\\s*[^%]\\+\\n\\)\\@<=\\s*%.*\\|\\(^\\s*%.*\\n\\)\\@<=\\s*[^%]\\+\\|\\(.*\\S\\+.*\\\\\\@<!%.*\\n\\)\\@<="
. "/-1\<cr>"
" 4.) Move to the end of the line
exec "normal $"
endfunction
" We set noshowcmd and noruler in order to suppress enter-prompt
" (see :help enter-prompt)
omap <silent> <buffer> lp :try \| let b:saved_showcmd=&l:showcmd \| let
b:saved_ruler=&l:ruler \| :setlocal noshowcmd noruler \| silent! call
g:Tex_SelectParagraph() \| finally \| let &l:showcmd=b:saved_showcmd \|
let &l:ruler=b:saved_ruler \| unlet b:saved_showcmd \| unlet
b:saved_ruler \| endtry<cr>
vmap <silent> <buffer> lp <esc>:try \| let b:saved_showcmd=&l:showcmd \|
let b:saved_ruler=&l:ruler \| :setlocal noshowcmd noruler \| silent!
call g:Tex_SelectParagraph() \| finally \| let
&l:showcmd=b:saved_showcmd \| let &l:ruler=b:saved_ruler \| unlet
b:saved_showcmd \| unlet b:saved_ruler \| endtry<cr>
" }}}
====
On 1/9/09 1:00 PM, Ted Pavlic wrote:
> In fact, even lines with comments at the end of them should be
> included... So another amendment:
...
> TODO: Find the top/bottom of a commented block.
--
Ted Pavlic <[email protected]>
Please visit my ALS association page:
http://web.alsa.org/goto/tedpavlic
My family appreciates your support in the fight to defeat ALS.
------------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It is the best place to buy or sell services for
just about anything Open Source.
http://p.sf.net/sfu/Xq1LFB
_______________________________________________
Vim-latex-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/vim-latex-devel