tags:

views:

84

answers:

2

Lorem ipsum dolor sit amet, hello consectetur adipiscing elit. Vivamus lorem mauris, dictum in ornare sit amet, vulputate at nibh. Integer volutpat justo vitae enim ultrices ultrices. In quis tortor id diam tincidunt feugiat at ut odio. Donec faucibus sapien vitae ante aliquam malesuada. Nam facilisis, metus in tincidunt posuere, hello massa nisi vulputate nunc, id rutrum mi enim non risus. Phasellus ac nisl non tortor pulvinar accumsan at eget leo. Nunc neque mauris, vehicula eget malesuada a, vestibulum non urna. Proin iaculis sem vel nulla porta tristique. Donec magna diam, eleifend quis vehicula in, aliquam in dolor. In et tellus nec metus volutpat dapibus. Duis hello purus dolor, aliquet in vehicula id, adipiscing id lorem. Vivamus elementum, mauris non vulputate tempus, risus elit tincidunt nunc, et posuere velit ligula sit amet purus. Integer pellentesque ultrices sodales. Donec in arcu eu est ullamcorper tincidunt placerat at sem.

I want select everything from the beginning until first occur of hello

I try this

/^.*hello

But it returns whole text until the last hello.

So how to do it?

+10  A: 

You can use the visual mode and then search for hello to extend it

0v/hello<cr>

should do it

Otherwise to do a "non-greedy" search you can try {-}

/^.\{-\}hello
mb14
+6  A: 

Just make the capture non-greedy:

/^.\{-}hello

This matches "as few as possible".

polemon