Tuesday, June 18, 2013

Re: g[lobal] with s[ubstitute]

On 2013-06-18 09:46, Christian Brabandt wrote:
> On Mon, June 17, 2013 01:12, Bee wrote:
> > Also if I use 'a' to replace all, search/replace does not exit,
> > again needing ^C.
> >
> > :g/}/s/;/; /gc
>
> So basically, you need to "quit"/"all" for each line again.
>
> Here is a patch, that makes "q" abort for all invocations of :s
> commands commands when used in conjuction with :g and 'a' work
> across all invocations of ':s' commands when using :g

I'm not sure Bram would except this, as it does break traditional
behavior. Granted, *MOST* of the time, your patch does what I want.
However, there have been times that I've wanted to have selective
control for a given block:

:g/Henry/'{;'}s/William/Mary/gc

where I want to review whether this particular paragraph containing
"Henry" is one in which I want to do the substitutions, in which case
I either do or don't want to do all the substitutions in the
paragraph. Your patch breaks that.

I think I'd prefer it as an extra response to the confirmation:

:g/foo/s/bar/baz/gc
...
replace with baz (y/n/a/A/q/Q/l/^E/^Y)?

where "Q" would quit globally like your patch does while "q" would
just quit for this invocation of :s and "A" would answer "All"
globally, while the "a" would do all of the replacements for the
current invocation. Ideally, this prompt would be dynamically created
so that the "A" and "Q" options only show up in the event we're
nested inside a :g command; if not inside a :g command then the
prompt remains as it currently is. From my quick testing here, Vim
ignores the capital letters when replying to this question, so it's
not like the new uses would mask behavior someone might have been
using.

-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/groups/opt_out.

No comments:

Post a Comment