I tested this again these test lines, doesn't work.
abc123 bla bla bla abc123 bla bla
abc123 bla bla bla abc1234 bla bla
abc123 bla bla bla abc123 bla bla
abc123 bla bla bla abc1234 bla bla
abc123 bla bla bla abc123 bla bla
abc123 bla bla bla abc1234 bla bla
abc123 bla bla bla abc123 bla bla
abc123 bla bla bla abc1234 bla bla
abc123 bla bla bla abc123 bla bla
:g#\(abc\d\+\)\(.*\)\(abc\d\+\)\(.*\)#s//\=Diff(submatch(1),submatch(2))/n
I got : "5 substitutions in 5 lines". no message got printed out...
any idea of what I missed here?
thanks anyway.
On Sat, Aug 10, 2013 at 9:06 PM, John Little <John.B.Little@gmail.com> wrote:
On Sunday, August 11, 2013 8:45:30 AM UTC+12, ping wrote:What you want is for submatch() to work in the context of :g. (Where's perl's $1, $2 ... when you want them...) You could fake it using a function and a substitute with the n flag:
>
> what I meant is, how to use these to actually do the compare in a vim ex command line?
> sth like :
>
> :g#\(abc\d\+) bla bla \(abc\d\+\)#if /1 != /2 then echo "found a diff !"
func! Diff(a,b)
if a:a != a:b
echo "found a diff!"
endif
endfunc
:g#\(abc\d\+) bla bla \(abc\d\+\)#s//\=Diff(submatch(1),submatch(2))/n
Regards, John Little
--
--
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
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
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
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment