These are all very useful additions.

I've just written some code for two new text objects: 'ae': an
environment; and 'ie': inner environment.  As far as I know, these
should work as long as your file is nicely indented.

" Section: an environment {{{
function! g:Tex_SelectAnEnvironment ()
        let i1 = indent('.')
        while ! (getline('.') =~ "\\\\begin" && indent('.') <= i1)
                exec "normal k0"
        endwhile
        exec "normal v"
        let i2 = indent('.')
        while ! (getline('.') =~ "\\\\end" && indent('.') == i2)
                exec "normal j$h"
        endwhile
endfunction
omap <buffer> ae :call g:Tex_SelectAnEnvironment()<cr>
vmap <buffer> ae <esc>:call g:Tex_SelectAnEnvironment()<cr>
" }}}
" Section: inner environment {{{
function! g:Tex_SelectInnerEnvironment ()
        let i1 = indent('.')
        while ! (getline('.') =~ "\\\\begin" && indent('.') <= i1)
                exec "normal k0"
        endwhile
        let i2 = indent('.')
        exec "normal jv"
        while ! (getline('.') =~ "\\\\end" && indent('.') == i2)
                exec "normal j$h"
        endwhile
        exec "normal k$h"
endfunction
omap <buffer> ie :call g:Tex_SelectInnerEnvironment()<cr>
vmap <buffer> ie <esc>:call g:Tex_SelectInnerEnvironment()<cr>
" }}}

I know the question has come up on this list before, but... if these
prove to be very useful additions to Latex-Suite (as I believe they
will) can they be added upstream as new features?

On Fri, Jan 9, 2009 at 1:00 PM, Ted Pavlic <t...@tedpavlic.com> wrote:
> In fact, even lines with comments at the end of them should be included...
> So another amendment:
>
> http://pastebin.com/f2f6e5633
>
> " Section: Paragraph formatting (autofill) {{{
> " Correctly format paragraphs in LaTeX.
> " The exec command should be one line: watch out if the e-mail client
> " or server inserts any line breaks.
> function! g:Tex_SelectParagraph ()
>    exec "normal
> ?^$\\|^.*\\([^\\\\]\\|\\)%\\|^\s*\\\\\\(begin\\|end\\|\\(new\\|renew\\|provide\\)com\\|def\\|[ls]et\\|label\\|item\\)?1\<cr>v//-1\<cr>$"
> endfunction
> omap <buffer> lp :call g:Tex_SelectParagraph()<cr>
> vmap <buffer> lp <esc>:call g:Tex_SelectParagraph()<cr>
> " }}}
>
> TODO: Find the top/bottom of a commented block.
>
> On 1/9/09 12:50 PM, Ted Pavlic wrote:
>>
>> Additionally, it's very important to check for a comment. That is, you
>> don't want to
>>
>> gwap
>>
>> with comments in your selection. So I added a ^\s*% to get what's at:
>>
>> http://pastebin.com/f4015755d
>>
>> Here it is here, with possible wrapping:
>>
>> " Section: Paragraph formatting (autofill) {{{
>> " Correctly format paragraphs in LaTeX.
>> " The exec command should be one line: watch out if the e-mail client
>> " or server inserts any line breaks.
>> function! g:Tex_SelectParagraph ()
>>      exec "normal
>>
>> ?^$\\|^\s*%\\|^\s*\\\\\\(begin\\|end\\|\\(new\\|renew\\|provide\\)com\\|def\\|[ls]et\\|label\\|item\\)?1\<cr>v//-1\<cr>$"
>> endfunction
>> omap<buffer>  lp :call g:Tex_SelectParagraph()<cr>
>> vmap<buffer>  lp<esc>:call g:Tex_SelectParagraph()<cr>
>> " }}}
>>
>> --Ted
>>
>> On 1/7/09 10:23 PM, Mike Richman wrote:
>>>
>>> " Section: Paragraph formatting (autofill) {{{
>>> " Correctly format paragraphs in LaTeX.
>>> " The exec command should be one line: watch out if the e-mail client
>>> " or server inserts any line breaks.
>>> function! g:Tex_SelectParagraph ()
>>>        exec "normal
>>> ?^$\\|^\s*\\(\\\\begin\\|\\\\end\\|\\\\renewcommand\\|\\\\label\\|\\\\item\\)?1\<cr>v//-1\<cr>$"
>>> endfunction
>>> omap<buffer>   lp :call g:Tex_SelectParagraph()<cr>
>>> vmap<buffer>   lp<esc>:call g:Tex_SelectParagraph()<cr>
>>> " }}}
>>
>
> --
> Ted Pavlic <t...@tedpavlic.com>
>
>  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
Vim-latex-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vim-latex-devel

Reply via email to