Given the lower priority of "\|" in parsing this is
1) any line containing "sample1"
2) or any line containing "sample2" twice
3) or (redundant to #1) any line containing "sample1"
It looks like you want to prioritize your pairings, something like
/^.*\%(\%(sample1.*sample2\)\|\%(sample2.*sample1\)\)
>
> is my best bet but I am still not there.
> 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, but Dr.
Chip has created LogiPat.vim[1] which might simplify some of
these sorts of things. If you have to do this sort of thing
frequently, that would be my first stop.
-tim
[1]
stable at
http://www.vim.org/scripts/script.php?script_id=1290
bleeding edge at
http://mysite.verizon.net/astronaut/vim/ index.html#LOGIPAT
If I'm understanding the problem correctly, I think you're looking for \&
/.*apple\&.*banana\&.*carrot
See :help /\&
~Matt
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