Wednesday, June 2, 2010

Re: Search for several words in each line with vim?

On Wed, June 2, 2010 4:29 pm, rewar wrote:
> Hi,
>
> I have looked around for a way to do this but just cant seem to find
> it. Basically, I have very large documents where I want to often
> search for a few words in a line, but they wont be all together.
>
> For example, I want to be able to find the line below in a large text
> document by simply searching "cat dog"
> "cats are smaller than dogs"
>

Try this:
/^\(.*cats.*\)\&\(.*dogs.*\)$

This finds any line which contains cats and dogs in any order.

> All editors I come across only allows you to search for an exact match
> of that field "cat dog" in any line.

There are probably several editors, that support regular expressions.
though probably not all of them have a that powerful RE-engine as Vim.

regards,
Christian

--
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: