Hi Matt!

On Mo, 04 Jan 2010, Matt Wozniski wrote:

> On Mon, Jan 4, 2010 at 1:12 PM, Tim Chase wrote:
> >> I am trying to put together a regexp to find pieces of text within one 
> >> line,
> >> but I do not know their order.
> ...
> >> Also, best if it would be flexible enough to support arbitrary number of
> >> samples without much typing.
> >
> > I don't think there's a natively nice way to do this
> 
> If I'm understanding the problem correctly, I think you're looking for \&
> 
>   /.*apple\&.*banana\&.*carrot
> 
> See :help /\&

And if you want to automate this, this could be helpful:
,----
| fu! <SID>SearchMultipleWordsInLine(...)
|     if a:0==1
|     return a:1
|     else
|     let a='.*\('.a:1.'\)1'
|     let j=a:2
|     let b=''
|     while j>1
|         let b.='\&.*\1'.(a:2-j+2)
|         let j-=1
|     endw
|     return a.b
|     endif
| endfu
| 
| com! -nargs=+ SearchMulti :let @/=<SID>SearchMultipleWordsInLine(<f-args>)
`----

And then do :SearchMulti sample 4


regards,
Christian
-- 
Moralisch schwächelnde Menschen haben in der katholischen Kirche schon
immer ihren Platz gefunden.
                -- Harald Schmidt

-- 
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php

Reply via email to