Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request for Ctrl+D (find next): if no text is selected, find next whole word; if selected, match all occurrences instead (like in Sublime) #19825

Closed
CanisLupus opened this issue Feb 3, 2017 · 11 comments
Assignees
Labels
*duplicate Issue identified as a duplicate of another issue(s) editor-multicursor Editor multiple cursor issues feature-request Request for new features or functionality
Milestone

Comments

@CanisLupus
Copy link

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:

wordword
word code word

And begin Ctrl+D'ing on the first standalone "word" in the second line, you will get:

wordword
[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.

@bpasero bpasero added the feature-request Request for new features or functionality label Feb 3, 2017
@alexdima
Copy link
Member

alexdima commented Feb 3, 2017

Mastering Cmd+D / Ctrl+D

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

image

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.

@alexdima alexdima closed this as completed Feb 3, 2017
@CanisLupus
Copy link
Author

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.

@CanisLupus
Copy link
Author

Can anyone please reopen this request or justify why it was closed?

@alexdima alexdima reopened this Feb 7, 2017
@alexdima alexdima added the editor-multicursor Editor multiple cursor issues label Feb 7, 2017
@CanisLupus
Copy link
Author

I appreciate that you reopened this. Thank you! :)

@alexdima
Copy link
Member

alexdima commented Feb 7, 2017

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.

@CanisLupus
Copy link
Author

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.

@atombender
Copy link

atombender commented Feb 26, 2017

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!

@jtomaszewski
Copy link

jtomaszewski commented Mar 28, 2017

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?

@alexdima alexdima added this to the On Deck milestone Jun 1, 2017
@alexdima
Copy link
Member

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.

@alexdima alexdima added the *duplicate Issue identified as a duplicate of another issue(s) label Oct 23, 2017
@alexdima alexdima modified the milestones: On Deck, October 2017 Oct 23, 2017
@CanisLupus
Copy link
Author

CanisLupus commented Oct 23, 2017

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?

@alexdima
Copy link
Member

@CanisLupus yes, that's exactly it. Thanks for spotting the copy-paste error :)

@vscodebot vscodebot bot locked and limited conversation to collaborators Dec 7, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*duplicate Issue identified as a duplicate of another issue(s) editor-multicursor Editor multiple cursor issues feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

5 participants