Hi,

Thank you for replying.

I use this command to put all matches on a new line:
:let @a=""<CR>:%s//\=setreg('A', submatch(0), 'l')/g<CR>:%d _<CR>:put
a<CR>:0d _<CR>

I can't find out how to keep them on the same line.

I tried this command:
%s/\(^\|\(hello\)\@<=\).\{-}\($\|hello\)\@=//g

It works with text but not with p.e. emails:
it removes the last character of every email. I tried many things to
change the command but I suppose I don't understand enough about
vimscript to find the solution.

Regards, R.

On Jun 20, 7:14 pm, Tim Chase <[email protected]> wrote:
> On 06/20/2011 11:35 AM, rameo wrote:
>
> > This is my command to search emails:
> > \([A-Z0-9+_.-]\+@\([A-Z0-9-]\+\.\)\+[A-Z]\{2,6}\)
>
> > p.e.
>
> > [email protected] hello [email protected]
> > hello [email protected]
>
> > Putting that in your command gives an empty output (it removes the
> > emails).
>
> Ah...with that context, I might try to approach the problem
> differently.  If you don't mind newlines being added when more
> than one email was on the same line, I might do something like
>
>   :%s/\([A-Z0-9+_.-]\+@\([A-Z0-9-]\+\.\)\+[A-Z]\{2,6}\)/\r&\r/g
>   :v/^\([A-Z0-9+_.-]\+@\([A-Z0-9-]\+\.\)\+[A-Z]\{2,6}\)$/d
>
> The first one puts each email address alone on a line, and the
> second one deletes all lines that don't have an email address on
> them.  Given your example, one might also have to add "\c" to
> your pattern to make it case-insensitive (your regexp only finds
> uppercase email addresses).
>
> If you need to keep emails on the same line back together, it
> might take a little more work.
>
> -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

Reply via email to