Friday, May 6, 2016

Re: why %s/b//gn doesn't work?

On 2016-05-06 19:19, 李哲 wrote:
> If I want to replace the `b` letter in the text with `null` and I
> also want to get the match number.
>
> so I use the command `%s/b//gn` , but I just get the count number
> but the `b` letter hasn't been replaced.
>
> If I use %s/b/a/gn it worked.

I get the same behavior in both cases (because of the /n flag,
neither actually performs the replacement. I recall there was a
patch that performed evaluations of the replacement in the case it
was a "\=" (sub-replace-special), but didn't actually replace the
text. I'd have to go digging for info to exactly which version/patch
that went into. Which version/patch-level are you currently running?

> I want to delete the `b` letter and the know the count number mean
> time . What should I do?

By default, Vim should report the count of changes if it exceeds your
'report' setting. Try

:set report=0

and re-try the command without the /n flag. If I understand what you
want, this should do the trick. If not, please clarify what you want
that isn't happening.

-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

---
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/d/optout.

No comments: