Sunday, September 23, 2012

Re: Redefining paragraph text object?

On 10:04 Sat 22 Sep , Gary Johnson wrote:
> On 2012-09-22, Christian Brabandt wrote:
> > Hi Gary!
> >
> > On Fr, 21 Sep 2012, Gary Johnson wrote:
> >
> > > On 2012-09-21, Silas Silva wrote:
> > > > Hello all.
> > > >
> > > > I was working around a function to map } and { around it. It is useful
> > > > for file formats that have other definitions of paragraph other than ^$.
> > > > For DocBook, for instance, it is better to use "<para>" and "</para>".
> > > >
> > > > So I thought: it works for navigation, but not for all other operations
> > > > regarding paragraph text object. Would it be possible to change
> > > > paragraph text object for my own needs?
> > > >
> > > > There is the 'paragraphs' option, but it look too simple, not accepting
> > > > regexp. I couldn't extend it far from the basic nroff setting.
> > > >
> > > > Is it possible?
> > >
> > > No.
> >
> > Not built in, but you can of course map { } to something different.
> > There are several text-object motion scripts at vim.org, this one here
> > seems to specifically take care of paragraph motion:
> > http://www.vim.org/scripts/script.php?script_id=3952
> >
> > Disclaimer: I don't know the plugin and can't say how well it will work
> > in your case.
>
> Mappings will work to change the behavior of { and }, but by "other
> operations regarding paragraph text object," I assumed the OP was
> referring to commands using ap and ip. There is no way that I know
> of to change the behavior of commands using those.

Then one can define visual maps and operator maps. In one of my plugins
I have:

vmap ip <Plug>SelectCurrentParagraph
omap ip :normal vip<CR> " omap, not onoremap

Similarly for ap. The <Plug>SelectCurrentParagraph is just a map which
selects a paragraph (I think I din't have to write this ;)

Best regards,
Marcin Szamotulski

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: