In Sublime Text, if you have nothing selected when you press Ctrl+D, it first selects the word where your cursor is at (VSCode also does this). Then, the next Ctrl+D will automatically use whole word search, regardless of the whole word setting.
If you have this:
word code word
And begin Ctrl+D'ing on the first standalone "word" in the second line, you will get:
[word] code [word]
(selections marked with [])
In contrast, if you already have text selected (with your mouse, or Shift+Arrow combinations), Ctrl+D will search WITHOUT whole word (i.e. matching all occurrences of the selected text even if they are not a complete token)
If select the first "word" in "wordword" with your mouse, you will get:
[word][word]
[word] code [word]
I hope my explanation was clear. :)
I understand that this might be something some users wouldn't want by default, but at least an option would be incredible, because this subtlety in Sublime avoids constantly changing whole word modes (case is respected either way) and I find it very productive.
The Add Selection To Next Find Match action (Cmd+D / Ctrl+D) and other related actions change their behaviour based on the find input state even if the find widget is hidden

The two toggles can be changed via keybindings even when the find widget is hidden:
| Option | Default keybinding |
|---|---|
| Match Case | Alt+C
Cmd+Alt+C (Mac) |
| Match Whole Word | Alt+W
Cmd+Alt+W (Mac) |
That is why, starting with VSCode 1.9.0, the find options will be revealed briefly or highlighted briefly whenever running this action.
I'm sorry, I don't think this should be closed when the reply doesn't address my suggestion or gives me a straight "no, we don't want to do that".
I know of the Alt+C and Alt+W combinations and have been using them for a while, even before the latest update made them more visible to the user. It is _precisely_ because I use them so much (mainly the "whole word" one) that I miss Sublime's behavior (the one I described), which lets me do what I want without touching the setting.
It was because of the most recent update to VSCode that I noticed that no one was paying attention to this, despite making the options more clear (and I thank you for that), so I decided to post here.
Can anyone please reopen this request or justify why it was closed?
I appreciate that you reopened this. Thank you! :)
Sorry for closing, I didn't read the issue with the attention I should have.
I've been thinking about this. I personally don't really like the idea of always honoring the match case, and honoring the whole words only in certain cases. i.e. if the selection is collapsed, and doing Ctrl+D, then forcing whole words.
I'm thinking if it would make sense that the first Ctrl+D in such a case (a collapsed selection) would flip the whole words and match case toggles on. It already "writes" to the find widget, i.e. the search string is replaced by the current word, so perhaps we could also "write" the match case and whole words toggles as well.
Thank you for your reply. I understand the problem with inconsistent usage of settings (whole vs case) and I wouldn't actually even recommend this as a default feature. :)
I was thinking of this more like an editor option for "addSelectionToNextFindMatch" (Ctrl+D); to be able to let the way your text is (or isn't) selected affect Ctrl+D's behavior (instead of the global setting), if you'd like that to happen. I also wasn't thinking of letting it alter the global whole word setting. That setting would be used pretty much for Find only. Ctrl+D would have its own, based on the selection.
That said, I realize that your suggestion is more sensible and seems to respect the current way VSCode does things. It's just that the Sublime way, though perhaps more "obtuse", has always been much more useful to me and at least another programmer I know of, to whom I mentioned this.
Thank you for considering this.
FWIW, Atom and Sublime Text both have the behaviour described by this issue, and the workflow is much more convenient. No UI is always better than UI when possible.
The case/word toggles are problematic in that they don't actually display until you hit the keyboard shortcuts, and they're tied to the Find/Replace popup; in other words, the mode is completely unpredictable. I, at least, don't remember what my last case/word toggle settings were from minute to minute!
Agree on that. As I use the Cmd+D extensively, that's the last thing that keeps me from full switch from Atom to vscode. I wonder if it could be written as a plugin, or it has to be done directly in the vscode core?
I believe this is resolved with PR #36682 (for #8869) . When starting with a collapsed selection, Command+D will now search with wholeWords: true and caseSensitive: true.
Great! So when starting with just the cursor (i.e. no selection i.e. "collapsed selection") it always uses whole words and is case sensitive. When there's a selection it respects whatever the find settings are.
Thank you for your work. :)
By the way, I believe you mean "non-collapsed" in the last bold "Find widget opened - starting with a collapsed selection" of your gifs, no?
@CanisLupus yes, that's exactly it. Thanks for spotting the copy-paste error :)
Most helpful comment
FWIW, Atom and Sublime Text both have the behaviour described by this issue, and the workflow is much more convenient. No UI is always better than UI when possible.
The case/word toggles are problematic in that they don't actually display until you hit the keyboard shortcuts, and they're tied to the Find/Replace popup; in other words, the mode is completely unpredictable. I, at least, don't remember what my last case/word toggle settings were from minute to minute!