Query replace with different replacements

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












Suppose we start with the following



Adam ate an apple.



Adam ate an apple.



Adam ate an apple.



Adam ate an apple.



Adam ate an apple.



I want to replace Adam with Bob, Chris, and David. So I want to do it such that I call a query-replace like function, search for Adam and then cycle through the results specifying what to replace it by.



I am guessing there are three possible answers here:
1. Write a function to do it, which I haven't tried.
2. There is a way to do it using query-replace like function which is what I am looking for.
3. I realize that I could do C-r during query-replace, but I was wondering if there was a way to avoid that.



Thank you for taking the time to answer my question! :)










share|improve this question

























    up vote
    1
    down vote

    favorite












    Suppose we start with the following



    Adam ate an apple.



    Adam ate an apple.



    Adam ate an apple.



    Adam ate an apple.



    Adam ate an apple.



    I want to replace Adam with Bob, Chris, and David. So I want to do it such that I call a query-replace like function, search for Adam and then cycle through the results specifying what to replace it by.



    I am guessing there are three possible answers here:
    1. Write a function to do it, which I haven't tried.
    2. There is a way to do it using query-replace like function which is what I am looking for.
    3. I realize that I could do C-r during query-replace, but I was wondering if there was a way to avoid that.



    Thank you for taking the time to answer my question! :)










    share|improve this question























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      Suppose we start with the following



      Adam ate an apple.



      Adam ate an apple.



      Adam ate an apple.



      Adam ate an apple.



      Adam ate an apple.



      I want to replace Adam with Bob, Chris, and David. So I want to do it such that I call a query-replace like function, search for Adam and then cycle through the results specifying what to replace it by.



      I am guessing there are three possible answers here:
      1. Write a function to do it, which I haven't tried.
      2. There is a way to do it using query-replace like function which is what I am looking for.
      3. I realize that I could do C-r during query-replace, but I was wondering if there was a way to avoid that.



      Thank you for taking the time to answer my question! :)










      share|improve this question













      Suppose we start with the following



      Adam ate an apple.



      Adam ate an apple.



      Adam ate an apple.



      Adam ate an apple.



      Adam ate an apple.



      I want to replace Adam with Bob, Chris, and David. So I want to do it such that I call a query-replace like function, search for Adam and then cycle through the results specifying what to replace it by.



      I am guessing there are three possible answers here:
      1. Write a function to do it, which I haven't tried.
      2. There is a way to do it using query-replace like function which is what I am looking for.
      3. I realize that I could do C-r during query-replace, but I was wondering if there was a way to avoid that.



      Thank you for taking the time to answer my question! :)







      query-replace






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 2 hours ago









      Quarky Quanta

      556




      556




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          3
          down vote



          accepted










          Assuming Bob is the first replacement:




          • M-% Adam RET Bob RET


          • y for all the consecutive Bob replacements


          • e to change the replacement string, to, e.g.: Chris RET


          • y for any further Chris replacements

          • etc...

          • When you want to re-use one of the previous replacements (say, Adam again)


          • e and then M-p or <up> to cycle back through the replacement history





          share|improve this answer




















            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "583"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2femacs.stackexchange.com%2fquestions%2f45077%2fquery-replace-with-different-replacements%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            3
            down vote



            accepted










            Assuming Bob is the first replacement:




            • M-% Adam RET Bob RET


            • y for all the consecutive Bob replacements


            • e to change the replacement string, to, e.g.: Chris RET


            • y for any further Chris replacements

            • etc...

            • When you want to re-use one of the previous replacements (say, Adam again)


            • e and then M-p or <up> to cycle back through the replacement history





            share|improve this answer
























              up vote
              3
              down vote



              accepted










              Assuming Bob is the first replacement:




              • M-% Adam RET Bob RET


              • y for all the consecutive Bob replacements


              • e to change the replacement string, to, e.g.: Chris RET


              • y for any further Chris replacements

              • etc...

              • When you want to re-use one of the previous replacements (say, Adam again)


              • e and then M-p or <up> to cycle back through the replacement history





              share|improve this answer






















                up vote
                3
                down vote



                accepted







                up vote
                3
                down vote



                accepted






                Assuming Bob is the first replacement:




                • M-% Adam RET Bob RET


                • y for all the consecutive Bob replacements


                • e to change the replacement string, to, e.g.: Chris RET


                • y for any further Chris replacements

                • etc...

                • When you want to re-use one of the previous replacements (say, Adam again)


                • e and then M-p or <up> to cycle back through the replacement history





                share|improve this answer












                Assuming Bob is the first replacement:




                • M-% Adam RET Bob RET


                • y for all the consecutive Bob replacements


                • e to change the replacement string, to, e.g.: Chris RET


                • y for any further Chris replacements

                • etc...

                • When you want to re-use one of the previous replacements (say, Adam again)


                • e and then M-p or <up> to cycle back through the replacement history






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 2 hours ago









                phils

                24.2k23361




                24.2k23361



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2femacs.stackexchange.com%2fquestions%2f45077%2fquery-replace-with-different-replacements%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Comments

                    Popular posts from this blog

                    What does second last employer means? [closed]

                    List of Gilmore Girls characters

                    Confectionery