Vscode: CMD+D should be smarter

Created on 30 Jul 2016  路  9Comments  路  Source: microsoft/vscode

  • VSCode Version: 1.4.0-insiders
  • OS Version: OSX

Steps to Reproduce:

  1. Create file with:
TEST
Test
aTesTer
test-123
test234
test
  1. Put cursor at position 1:1 and press CMD+D 7 times
  2. VS Code selects:

image

It should only select next matches using case sensitivity and whole words

Here is Atom result for the same:

image

*duplicate editor editor-multicursor feature-request

Most helpful comment

I recommend that VSCode adopt the behaviour that Atom has, and which I believe Sublime also has: If you don't start with a selection, then whole-word matching is implicit.

For example: If I have the cursor at the beginning of the word "foo", then cmd-D will only match whole-word instances of "foo". If I _select_ "foo", then cmd-D will match any substring.

This is extremely convenient as a shorthand.

FWIW, I personally find the feature where cmd-D respects the Find panel's case/whole-word settings to be quite exhausting. The setting I need is usually different every time I need to use cmd-D. I continually have to hit cmd-alt-c, cmd-alt-w in order to toggle these (and I rely on cmd-D a _lot_). My above suggestion will reduce the necessary keypresses to just one key, which would help greatly.

All 9 comments

FYI, Sublime Text utilise the settings from Find panel in order to match these words.

@wallverb cmd+d respects the find widget settings which can be toggled via keyboard (match whole word, case sensitivty)

I recommend that VSCode adopt the behaviour that Atom has, and which I believe Sublime also has: If you don't start with a selection, then whole-word matching is implicit.

For example: If I have the cursor at the beginning of the word "foo", then cmd-D will only match whole-word instances of "foo". If I _select_ "foo", then cmd-D will match any substring.

This is extremely convenient as a shorthand.

FWIW, I personally find the feature where cmd-D respects the Find panel's case/whole-word settings to be quite exhausting. The setting I need is usually different every time I need to use cmd-D. I continually have to hit cmd-alt-c, cmd-alt-w in order to toggle these (and I rely on cmd-D a _lot_). My above suggestion will reduce the necessary keypresses to just one key, which would help greatly.

This behavior is the only thing keeping me from switching to VS Code. It's unfortunate when I decide to rename a variable like "i" and it starts selecting random i's in the middle of other words. It ruins the refactor use-case of multiple cursors.

Indeed. Replying to myself to make another important point:

The setting I need is usually different every time I need to use cmd-D.

...and it's exacerbated by the fact that you don't _know_ what the case/word toggles are set to unless you hit cmd-F. Almost every time I use the cmd-D feature, not only are the toggles wrong, but I have to do a cmd-F just to see what the toggles are set to.

The new version (1.9) semi-addresses the problem by making the toggle states visible when using Ctrl+D, but I don't see why these states are shared with the search functionality at this point. Doing this has probably added more complexity when compared to Sublime's behavior as described by @atombender

Isn't this already addressed?

Press CMD + f
You'll need to toggle Match case and Match whole words option:

image

Then it'll work as expected:
image

I'm pretty sure that sublime also behaves this way

@jameslieu: No, Sublime does not work that way. Read my explanation. Sublime always uses whole-word matching unless you explicitly make a selection before hitting cmd-D. It's a superior workflow and reduces the need for a whole-word toggle for cmd-D.

@alexandrudima: Looks to me like this issue is being ignored. Any way we can move it forward?

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chrisdias picture chrisdias  路  3Comments

curtw picture curtw  路  3Comments

lukehoban picture lukehoban  路  3Comments

NikosEfthias picture NikosEfthias  路  3Comments

VitorLuizC picture VitorLuizC  路  3Comments