Loading ...
Sorry, an error occurred while loading the content.

Re: g[lobal] with s[ubstitute]

Expand Messages
  • Christian Brabandt
    Hi Tim! ... Attached is an updated patch, implementing your suggestions, as well as a hit ? to show a help banner. Bram, if this gets merged, I think it
    Message 1 of 10 , Jun 18, 2013
    • 0 Attachment
      Hi Tim!

      On Di, 18 Jun 2013, Tim Chase wrote:

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

      Attached is an updated patch, implementing your suggestions, as well as
      a hit '?' to show a help banner.

      Bram, if this gets merged, I think it makes sense to also merge the 'u'
      flag for undo the last substitution (that I have posted a while ago).

      regards,
      Christian

      --
      --
      You received this message from the "vim_dev" 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_dev" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Bram Moolenaar
      ... Do they interfere? It s always better to keep change separate if possible, so that when one of them causes trouble we can revert it. ... This name is a
      Message 2 of 10 , Jun 18, 2013
      • 0 Attachment
        Christian Brabandt wrote:

        > On Di, 18 Jun 2013, Tim Chase wrote:
        >
        > > 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.
        >
        > Attached is an updated patch, implementing your suggestions, as well as
        > a hit '?' to show a help banner.
        >
        > Bram, if this gets merged, I think it makes sense to also merge the 'u'
        > flag for undo the last substitution (that I have posted a while ago).

        Do they interfere? It's always better to keep change separate if
        possible, so that when one of them causes trouble we can revert it.

        > {
        > sub_nsubs = 0;
        > sub_nlines = 0;
        > + global_do_ask = TRUE;

        This name is a bit confusing, since it doesn't actually switch on
        asking. How about global_stop_asking? It's set to FALSE at the start
        and end of :global, when A or Q is typed then it's set to TRUE.


        --
        hundred-and-one symptoms of being an internet addict:
        246. You use up your free 100 hours in less than a week.

        /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
        /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
        \\\ an exciting new programming language -- http://www.Zimbu.org ///
        \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

        --
        --
        You received this message from the "vim_dev" 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_dev" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • Christian Brabandt
        ... Ok. I just meant, when you are including that one patch, you might also include the other, since both enhance the confirmation dialog for ... Here is an
        Message 3 of 10 , Jun 18, 2013
        • 0 Attachment
          On Tue, June 18, 2013 22:10, Bram Moolenaar wrote:
          >> Attached is an updated patch, implementing your suggestions, as well as
          >> a hit '?' to show a help banner.
          >>
          >> Bram, if this gets merged, I think it makes sense to also merge the 'u'
          >> flag for undo the last substitution (that I have posted a while ago).
          >
          > Do they interfere? It's always better to keep change separate if
          > possible, so that when one of them causes trouble we can revert it.

          Ok. I just meant, when you are including that one patch, you might also
          include the other, since both enhance the confirmation dialog for
          :s command.

          >
          >> {
          >> sub_nsubs = 0;
          >> sub_nlines = 0;
          >> + global_do_ask = TRUE;
          >
          > This name is a bit confusing, since it doesn't actually switch on
          > asking. How about global_stop_asking? It's set to FALSE at the start
          > and end of :global, when A or Q is typed then it's set to TRUE.

          Here is an updated patch.

          regards,
          Christian

          --
          --
          You received this message from the "vim_dev" 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_dev" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.
        • Bram Moolenaar
          ... Thanks. I ll add it to the todo list and look into it later. -- Emacs is a nice OS - but it lacks a good text editor. That s why I am using Vim.
          Message 4 of 10 , Jun 19, 2013
          • 0 Attachment
            Christian Brabandt wrote:

            > On Tue, June 18, 2013 22:10, Bram Moolenaar wrote:
            > >> Attached is an updated patch, implementing your suggestions, as well as
            > >> a hit '?' to show a help banner.
            > >>
            > >> Bram, if this gets merged, I think it makes sense to also merge the 'u'
            > >> flag for undo the last substitution (that I have posted a while ago).
            > >
            > > Do they interfere? It's always better to keep change separate if
            > > possible, so that when one of them causes trouble we can revert it.
            >
            > Ok. I just meant, when you are including that one patch, you might also
            > include the other, since both enhance the confirmation dialog for
            > :s command.
            >
            > >
            > >> {
            > >> sub_nsubs = 0;
            > >> sub_nlines = 0;
            > >> + global_do_ask = TRUE;
            > >
            > > This name is a bit confusing, since it doesn't actually switch on
            > > asking. How about global_stop_asking? It's set to FALSE at the start
            > > and end of :global, when A or Q is typed then it's set to TRUE.
            >
            > Here is an updated patch.

            Thanks. I'll add it to the todo list and look into it later.

            --
            Emacs is a nice OS - but it lacks a good text editor.
            That's why I am using Vim. --Anonymous

            /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
            /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
            \\\ an exciting new programming language -- http://www.Zimbu.org ///
            \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

            --
            --
            You received this message from the "vim_dev" 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_dev" group.
            To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
            For more options, visit https://groups.google.com/groups/opt_out.
          • Bee
            Hello Bram Will this patch be incorporated in 7.3.xxxx? Bill g[lobal] with s[ubstitute] https://groups.google.com/forum/m/#!topic/vim_use/S5MiwpqCzDc ...
            Message 5 of 10 , Jul 5, 2013
            • 0 Attachment
              Hello Bram

              Will this patch be incorporated in 7.3.xxxx?

              Bill

              g[lobal] with s[ubstitute]
              https://groups.google.com/forum/m/#!topic/vim_use/S5MiwpqCzDc

              On Di, 18 Jun 2013, Tim Chase wrote:
              > 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.

              Attached is an updated patch, implementing your suggestions, as well as
              a hit '?' to show a help banner.

              Bram, if this gets merged, I think it makes sense to also merge the 'u'
              flag for undo the last substitution (that I have posted a while ago).

              regards,
              Christian
              Attachments (1)

              global_subst_confirm_msg.diff

              --
              --
              You received this message from the "vim_dev" 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_dev" group.
              To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
              For more options, visit https://groups.google.com/groups/opt_out.
            • Zulox4
              ... it would be nice to have this feature ! -- -- You received this message from the vim_dev maillist. Do not top-post! Type your reply below the text you
              Message 6 of 10 , Jul 5, 2013
              • 0 Attachment
                On Friday, July 5, 2013 10:18:12 PM UTC+2, Bee wrote:
                > Hello Bram
                >
                > Will this patch be incorporated in 7.3.xxxx?
                >
                > Bill
                >
                > g[lobal] with s[ubstitute]
                > https://groups.google.com/forum/m/#!topic/vim_use/S5MiwpqCzDc
                >
                > On Di, 18 Jun 2013, Tim Chase wrote:
                > > 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.
                >
                > Attached is an updated patch, implementing your suggestions, as well as
                > a hit '?' to show a help banner.
                >
                > Bram, if this gets merged, I think it makes sense to also merge the 'u'
                > flag for undo the last substitution (that I have posted a while ago).
                >
                > regards,
                > Christian
                > Attachments (1)
                >
                > global_subst_confirm_msg.diff

                it would be nice to have this feature !

                --
                --
                You received this message from the "vim_dev" 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_dev" group.
                To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
                For more options, visit https://groups.google.com/groups/opt_out.
              • Roland Eggner
                ... +1 ... +1 -- Roland Eggner
                Message 7 of 10 , Jul 6, 2013
                • 0 Attachment
                  On 2013-07-05 Friday at 22:21 -0700 Zulox4 wrote:
                  > On Friday, July 5, 2013 10:18:12 PM UTC+2, Bee wrote:
                  > > Hello Bram
                  > >
                  > > Will this patch be incorporated in 7.3.xxxx?
                  > >
                  > > Bill
                  > >
                  > > g[lobal] with s[ubstitute]
                  > > https://groups.google.com/forum/m/#!topic/vim_use/S5MiwpqCzDc
                  > >
                  > > On Di, 18 Jun 2013, Tim Chase wrote:
                  > > > 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.
                  > >
                  > > Attached is an updated patch, implementing your suggestions, as well as
                  > > a hit '?' to show a help banner.
                  > >
                  > > Bram, if this gets merged, I think it makes sense to also merge the 'u'
                  > > flag for undo the last substitution (that I have posted a while ago).

                  +1

                  > >
                  > > regards,
                  > > Christian
                  > > Attachments (1)
                  > >
                  > > global_subst_confirm_msg.diff
                  >
                  > it would be nice to have this feature !

                  +1

                  --
                  Roland Eggner
                • Bram Moolenaar
                  ... Nope, it s time for a beta release. The todo list is full of useful patches, I have to stop somewhere. -- I bought a book on hair loss, but the pages kept
                  Message 8 of 10 , Jul 6, 2013
                  • 0 Attachment
                    Bill Bee wrote:

                    > Will this patch be incorporated in 7.3.xxxx?

                    Nope, it's time for a beta release.

                    The todo list is full of useful patches, I have to stop somewhere.


                    --
                    I bought a book on hair loss, but the pages kept falling out.

                    /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
                    /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
                    \\\ an exciting new programming language -- http://www.Zimbu.org ///
                    \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

                    --
                    --
                    You received this message from the "vim_dev" 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_dev" group.
                    To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
                    For more options, visit https://groups.google.com/groups/opt_out.
                  Your message has been successfully submitted and would be delivered to recipients shortly.