Monday, June 20, 2011

Re: remove all except pattern

On 06/20/2011 10:00 AM, rameo wrote:

> hello this is an example, hello to everybody
> hello
>
> this is the output of the text when I use your command %s/\w\+\W*/
> \=submatch(0)=~'hello'?submatch(0):'' :
>
> hello this is an example, hello to everybody
> hello

Ah...it looks like it was missing the "g" flag at the end:

:%s/\w\+\W*/\=submatch(0)=~'hello'?submatch(0):''/g

Something must not have copied over when I pasted it into the
original email.

-tim


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