Reputation: 456
When you press 'ctrl+f' in sublime text, there is an option (a button that looks kind of like: "") which makes it so it only finds 'whole words'.
Now, suppose I have the following code:
word
longword
word
and I have the first occurrence of the word 'word' selected. If I press ctrl+d, it selects the last four letters of the word 'longword', instead of selecting the next 'whole word' occurrence of 'word'. Is there any way to change this?
Upvotes: 2
Views: 1195
Reputation: 2245
I know this is late. But I have just done a plugin that exactly solves this problem, in a straightforward, explicit and complete way.
It's called Exact Quick Find
and is available on Package Control here.
This plugin implements Quick Find / Quick Add subject to case-sensitive and whole-word restrictions.
The restriction flags (e.g. uppercase [W]
for whole-word) are always displayed on the status bar, and you can easily toggle them with key bindings.
The screencast demonstrates searching for the exact word "debug"
in lowercase.
Note that the search skips all the non-whole-word cases such as "_debug_print"
and "debug_level"
.
For your case,
word
longword
word
No matter you have selected the entire word "word"
, or just placed your cursor inside "word"
, with the whole-word flag on [W]
, you can readily go to or add the next match.
Use Exact Quick Find: Goto Next
to go to the next (whole-word) match
Use Exact Quick Find: Add Next
to add the next (whole-word) match
Upvotes: 2
Reputation: 22791
Quick Add Next
is sensitive to what's selected when you invoke the command, so that it can be used in multiple different types of circumstances; it does different things depending on whether something is selected or not.
If some text is selected, the result is that the next occurrence of that text will be found and added to the selection, irrespective of any word boundaries that might exist, which is what you're describing in your question.
The work flow here is to find other instances of the text that's selected as a partial match. So if you need to search for things outside of word boundaries, this is how you would go about that.
If no text is selected, invoking the command will expand the selection out to the whole word (in fact Selection > Expand selection to word
and Find > Quick Add Next
are bound to the same command).
In this case, the word becomes selected as a result of the command, and repeated executions of the command will find the next item with the same word boundaries as was used to find the first item. This is what you're trying to accomplish here.
The work flow in this case is that you want to find other instances of an exact word (such as when working with code and you want to quickly find and replace to swap a variable or function name to something else, etc).
Upvotes: 4