Sublime Text 3 - Quick Add/Find Match behavior












13















Suppose I'm working with a file In Sublime Text 3 that contains multiple occurrences of a single character variable, c, which I want to rename to another name.



When I select one instance of that variable with my cursor, Sublime Text automatically highlights the other instances of that variable for me:



This visual highlight is enabled by the the setting: "match_selection": true, and clearly shows that sublime is smart enough to only highlight other instances of that character where it is relevant as a variable.



However despite this highlight indicating that it should be possible, it seems there is no easy way to now automatically select just these highlighted c variables.



If I want to quickly rename all instances of the variable c using multiple cursors, either with Quick Add Next (cmd+D) or Quick Find All (ctrl+cmd+G) instead of selecting only that variable c, I get every single instance of the character 'c' selected:



This is obviously not useful at all, since it has no correlation to the actual variable; It just blindly selected all letters "c", regardless of if they are the selected variable or not.



Is there a way to force Quick Add Next and Quick Find All, to behave like the highlighting rules that the match_selection setting uses? This would be much more useful in this case than simply blindly selecting every instance of the selected character(s).



Am I missing something? I can't find a Quick Find All Instances or Quick Add Next Variable option, or any way to customize the default behavior of Quick Find All and Quick Add Next. As far as I can tell, my only options are to either manually rename every instance of c, or write some custom regex to achieve the same result as the original highlighting algorithm.










share|improve this question





























    13















    Suppose I'm working with a file In Sublime Text 3 that contains multiple occurrences of a single character variable, c, which I want to rename to another name.



    When I select one instance of that variable with my cursor, Sublime Text automatically highlights the other instances of that variable for me:



    This visual highlight is enabled by the the setting: "match_selection": true, and clearly shows that sublime is smart enough to only highlight other instances of that character where it is relevant as a variable.



    However despite this highlight indicating that it should be possible, it seems there is no easy way to now automatically select just these highlighted c variables.



    If I want to quickly rename all instances of the variable c using multiple cursors, either with Quick Add Next (cmd+D) or Quick Find All (ctrl+cmd+G) instead of selecting only that variable c, I get every single instance of the character 'c' selected:



    This is obviously not useful at all, since it has no correlation to the actual variable; It just blindly selected all letters "c", regardless of if they are the selected variable or not.



    Is there a way to force Quick Add Next and Quick Find All, to behave like the highlighting rules that the match_selection setting uses? This would be much more useful in this case than simply blindly selecting every instance of the selected character(s).



    Am I missing something? I can't find a Quick Find All Instances or Quick Add Next Variable option, or any way to customize the default behavior of Quick Find All and Quick Add Next. As far as I can tell, my only options are to either manually rename every instance of c, or write some custom regex to achieve the same result as the original highlighting algorithm.










    share|improve this question



























      13












      13








      13


      2






      Suppose I'm working with a file In Sublime Text 3 that contains multiple occurrences of a single character variable, c, which I want to rename to another name.



      When I select one instance of that variable with my cursor, Sublime Text automatically highlights the other instances of that variable for me:



      This visual highlight is enabled by the the setting: "match_selection": true, and clearly shows that sublime is smart enough to only highlight other instances of that character where it is relevant as a variable.



      However despite this highlight indicating that it should be possible, it seems there is no easy way to now automatically select just these highlighted c variables.



      If I want to quickly rename all instances of the variable c using multiple cursors, either with Quick Add Next (cmd+D) or Quick Find All (ctrl+cmd+G) instead of selecting only that variable c, I get every single instance of the character 'c' selected:



      This is obviously not useful at all, since it has no correlation to the actual variable; It just blindly selected all letters "c", regardless of if they are the selected variable or not.



      Is there a way to force Quick Add Next and Quick Find All, to behave like the highlighting rules that the match_selection setting uses? This would be much more useful in this case than simply blindly selecting every instance of the selected character(s).



      Am I missing something? I can't find a Quick Find All Instances or Quick Add Next Variable option, or any way to customize the default behavior of Quick Find All and Quick Add Next. As far as I can tell, my only options are to either manually rename every instance of c, or write some custom regex to achieve the same result as the original highlighting algorithm.










      share|improve this question
















      Suppose I'm working with a file In Sublime Text 3 that contains multiple occurrences of a single character variable, c, which I want to rename to another name.



      When I select one instance of that variable with my cursor, Sublime Text automatically highlights the other instances of that variable for me:



      This visual highlight is enabled by the the setting: "match_selection": true, and clearly shows that sublime is smart enough to only highlight other instances of that character where it is relevant as a variable.



      However despite this highlight indicating that it should be possible, it seems there is no easy way to now automatically select just these highlighted c variables.



      If I want to quickly rename all instances of the variable c using multiple cursors, either with Quick Add Next (cmd+D) or Quick Find All (ctrl+cmd+G) instead of selecting only that variable c, I get every single instance of the character 'c' selected:



      This is obviously not useful at all, since it has no correlation to the actual variable; It just blindly selected all letters "c", regardless of if they are the selected variable or not.



      Is there a way to force Quick Add Next and Quick Find All, to behave like the highlighting rules that the match_selection setting uses? This would be much more useful in this case than simply blindly selecting every instance of the selected character(s).



      Am I missing something? I can't find a Quick Find All Instances or Quick Add Next Variable option, or any way to customize the default behavior of Quick Find All and Quick Add Next. As far as I can tell, my only options are to either manually rename every instance of c, or write some custom regex to achieve the same result as the original highlighting algorithm.







      keyboard-shortcuts selection sublime-text-3 default-settings sublime-text






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 11 at 19:54









      Glorfindel

      1,38441220




      1,38441220










      asked Apr 16 '14 at 12:34









      JohannesJohannes

      17118




      17118






















          2 Answers
          2






          active

          oldest

          votes


















          21














          The trick is to start with an empty selection, with your cursor just to the left of the word you want to select. Then, hit CtrlG (or AltF3 on Windows/Linux) to select all instances of that word:



          lua code



          or hit D (CtrlD on Win/Lin) to begin selecting them one at a time.






          share|improve this answer



















          • 1





            Basically exactly what I was looking for, cheers :) -

            – Johannes
            Apr 19 '14 at 17:33











          • This works if you want all of them in a file; I just want all of them that are closeby, like you get with Ctrl+D.

            – Ben Dilts
            Jan 13 '15 at 18:43











          • @BenDilts I'm not sure what you're asking. What are you trying to do?

            – MattDMo
            Jan 13 '15 at 18:47











          • Say you have a file with ten different methods, each of which has a local variable named "c". I just want to rapidly select the ones in a smaller area than the whole file.

            – Ben Dilts
            Jan 13 '15 at 21:48






          • 2





            @BenDilts Put your cursor just to the left of the first one, and select the ones you want using Ctrl-D, just like I said in my answer.

            – MattDMo
            Jan 13 '15 at 21:53



















          0














          When selecting and renaming all occurrences of a variable, this does not imply that all strings are to be renamed.
          For example 'c' may occur in many words, not being variables.
          In order to ONLY rename the occurrences that are variables one can use the anaconda add-on:




          Right-mouse-click the variable



          Select Anaconda -> Rename Object under cursor



          Ps. One can Double-click the variable to check what the selection would be before executing the renaming.







          share|improve this answer























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "3"
            };
            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',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f742438%2fsublime-text-3-quick-add-find-match-behavior%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            21














            The trick is to start with an empty selection, with your cursor just to the left of the word you want to select. Then, hit CtrlG (or AltF3 on Windows/Linux) to select all instances of that word:



            lua code



            or hit D (CtrlD on Win/Lin) to begin selecting them one at a time.






            share|improve this answer



















            • 1





              Basically exactly what I was looking for, cheers :) -

              – Johannes
              Apr 19 '14 at 17:33











            • This works if you want all of them in a file; I just want all of them that are closeby, like you get with Ctrl+D.

              – Ben Dilts
              Jan 13 '15 at 18:43











            • @BenDilts I'm not sure what you're asking. What are you trying to do?

              – MattDMo
              Jan 13 '15 at 18:47











            • Say you have a file with ten different methods, each of which has a local variable named "c". I just want to rapidly select the ones in a smaller area than the whole file.

              – Ben Dilts
              Jan 13 '15 at 21:48






            • 2





              @BenDilts Put your cursor just to the left of the first one, and select the ones you want using Ctrl-D, just like I said in my answer.

              – MattDMo
              Jan 13 '15 at 21:53
















            21














            The trick is to start with an empty selection, with your cursor just to the left of the word you want to select. Then, hit CtrlG (or AltF3 on Windows/Linux) to select all instances of that word:



            lua code



            or hit D (CtrlD on Win/Lin) to begin selecting them one at a time.






            share|improve this answer



















            • 1





              Basically exactly what I was looking for, cheers :) -

              – Johannes
              Apr 19 '14 at 17:33











            • This works if you want all of them in a file; I just want all of them that are closeby, like you get with Ctrl+D.

              – Ben Dilts
              Jan 13 '15 at 18:43











            • @BenDilts I'm not sure what you're asking. What are you trying to do?

              – MattDMo
              Jan 13 '15 at 18:47











            • Say you have a file with ten different methods, each of which has a local variable named "c". I just want to rapidly select the ones in a smaller area than the whole file.

              – Ben Dilts
              Jan 13 '15 at 21:48






            • 2





              @BenDilts Put your cursor just to the left of the first one, and select the ones you want using Ctrl-D, just like I said in my answer.

              – MattDMo
              Jan 13 '15 at 21:53














            21












            21








            21







            The trick is to start with an empty selection, with your cursor just to the left of the word you want to select. Then, hit CtrlG (or AltF3 on Windows/Linux) to select all instances of that word:



            lua code



            or hit D (CtrlD on Win/Lin) to begin selecting them one at a time.






            share|improve this answer













            The trick is to start with an empty selection, with your cursor just to the left of the word you want to select. Then, hit CtrlG (or AltF3 on Windows/Linux) to select all instances of that word:



            lua code



            or hit D (CtrlD on Win/Lin) to begin selecting them one at a time.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Apr 19 '14 at 17:05









            MattDMoMattDMo

            4,8081628




            4,8081628








            • 1





              Basically exactly what I was looking for, cheers :) -

              – Johannes
              Apr 19 '14 at 17:33











            • This works if you want all of them in a file; I just want all of them that are closeby, like you get with Ctrl+D.

              – Ben Dilts
              Jan 13 '15 at 18:43











            • @BenDilts I'm not sure what you're asking. What are you trying to do?

              – MattDMo
              Jan 13 '15 at 18:47











            • Say you have a file with ten different methods, each of which has a local variable named "c". I just want to rapidly select the ones in a smaller area than the whole file.

              – Ben Dilts
              Jan 13 '15 at 21:48






            • 2





              @BenDilts Put your cursor just to the left of the first one, and select the ones you want using Ctrl-D, just like I said in my answer.

              – MattDMo
              Jan 13 '15 at 21:53














            • 1





              Basically exactly what I was looking for, cheers :) -

              – Johannes
              Apr 19 '14 at 17:33











            • This works if you want all of them in a file; I just want all of them that are closeby, like you get with Ctrl+D.

              – Ben Dilts
              Jan 13 '15 at 18:43











            • @BenDilts I'm not sure what you're asking. What are you trying to do?

              – MattDMo
              Jan 13 '15 at 18:47











            • Say you have a file with ten different methods, each of which has a local variable named "c". I just want to rapidly select the ones in a smaller area than the whole file.

              – Ben Dilts
              Jan 13 '15 at 21:48






            • 2





              @BenDilts Put your cursor just to the left of the first one, and select the ones you want using Ctrl-D, just like I said in my answer.

              – MattDMo
              Jan 13 '15 at 21:53








            1




            1





            Basically exactly what I was looking for, cheers :) -

            – Johannes
            Apr 19 '14 at 17:33





            Basically exactly what I was looking for, cheers :) -

            – Johannes
            Apr 19 '14 at 17:33













            This works if you want all of them in a file; I just want all of them that are closeby, like you get with Ctrl+D.

            – Ben Dilts
            Jan 13 '15 at 18:43





            This works if you want all of them in a file; I just want all of them that are closeby, like you get with Ctrl+D.

            – Ben Dilts
            Jan 13 '15 at 18:43













            @BenDilts I'm not sure what you're asking. What are you trying to do?

            – MattDMo
            Jan 13 '15 at 18:47





            @BenDilts I'm not sure what you're asking. What are you trying to do?

            – MattDMo
            Jan 13 '15 at 18:47













            Say you have a file with ten different methods, each of which has a local variable named "c". I just want to rapidly select the ones in a smaller area than the whole file.

            – Ben Dilts
            Jan 13 '15 at 21:48





            Say you have a file with ten different methods, each of which has a local variable named "c". I just want to rapidly select the ones in a smaller area than the whole file.

            – Ben Dilts
            Jan 13 '15 at 21:48




            2




            2





            @BenDilts Put your cursor just to the left of the first one, and select the ones you want using Ctrl-D, just like I said in my answer.

            – MattDMo
            Jan 13 '15 at 21:53





            @BenDilts Put your cursor just to the left of the first one, and select the ones you want using Ctrl-D, just like I said in my answer.

            – MattDMo
            Jan 13 '15 at 21:53













            0














            When selecting and renaming all occurrences of a variable, this does not imply that all strings are to be renamed.
            For example 'c' may occur in many words, not being variables.
            In order to ONLY rename the occurrences that are variables one can use the anaconda add-on:




            Right-mouse-click the variable



            Select Anaconda -> Rename Object under cursor



            Ps. One can Double-click the variable to check what the selection would be before executing the renaming.







            share|improve this answer




























              0














              When selecting and renaming all occurrences of a variable, this does not imply that all strings are to be renamed.
              For example 'c' may occur in many words, not being variables.
              In order to ONLY rename the occurrences that are variables one can use the anaconda add-on:




              Right-mouse-click the variable



              Select Anaconda -> Rename Object under cursor



              Ps. One can Double-click the variable to check what the selection would be before executing the renaming.







              share|improve this answer


























                0












                0








                0







                When selecting and renaming all occurrences of a variable, this does not imply that all strings are to be renamed.
                For example 'c' may occur in many words, not being variables.
                In order to ONLY rename the occurrences that are variables one can use the anaconda add-on:




                Right-mouse-click the variable



                Select Anaconda -> Rename Object under cursor



                Ps. One can Double-click the variable to check what the selection would be before executing the renaming.







                share|improve this answer













                When selecting and renaming all occurrences of a variable, this does not imply that all strings are to be renamed.
                For example 'c' may occur in many words, not being variables.
                In order to ONLY rename the occurrences that are variables one can use the anaconda add-on:




                Right-mouse-click the variable



                Select Anaconda -> Rename Object under cursor



                Ps. One can Double-click the variable to check what the selection would be before executing the renaming.








                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Feb 4 '17 at 10:58









                LeoLeo

                11




                11






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Super User!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f742438%2fsublime-text-3-quick-add-find-match-behavior%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    How to make a Squid Proxy server?

                    Is this a new Fibonacci Identity?

                    19世紀