Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

up vote 2 down vote accepted

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
    
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 at 18:43
    
@BenDilts I'm not sure what you're asking. What are you trying to do? –  MattDMo Jan 13 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 at 21:48
1  
@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 at 21:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.