alefragnani / vscode-copy-word

Copy Word Extension for Visual Studio Code
MIT License
11 stars 4 forks source link

Select word w/o copying it #11

Closed wasker closed 4 years ago

wasker commented 4 years ago

That'd be great to be able to just select the word, without copying it.

alefragnani commented 4 years ago

Hi @wasker ,

Do you know the native Add Selection to Next Find Match command does exactly this?

Just hit Cmd + D (on Mac) / Ctrl + D (on Win/Linux) and it will select the word in the cursor position. BTW, if you hit the same command again and again, it will select the other occurrences of the same word.

Hope this helps

wasker commented 4 years ago

I would never know by the name of it... Thanks for pointing me there!

alefragnani commented 4 years ago

Me neither, but this keyboard shortcut was one of the first productivity features I’ve learned in VSCode, so I use it a lot 😁 .

wasker commented 4 years ago

I wonder if you'd reconsider reopening this issue. Ctrl-D is better than nothing, but it doesn't behave like Ctrl-Shift-W in Visual Studio 2019. :( It doesn't really select words, and it looks like behavior in general depends on the language in the editor. E.g., if I Ctrl-D on "workbench" in the file below, the whole string with double-quotes gets selected. And this behavior is a bit different in e.g. if PowerShell script is opened in the editor.

{ "key": "ctrl+shift+s",       "command": "workbench.action.files.saveAll" }
wasker commented 4 years ago

Also, sorry to bug you - it's just you're the person who already has extension for operations on words, and simple word selection seem to be logical to have there too. :)

alefragnani commented 4 years ago

No problem, you are not bugging me 😁 .

I'm not familiar with VS2019, so I don't know how it works. I made a search and found this documentation, which says different things about the commands. Maybe you used a different release or has some plugin installed.

Command Shortcut
Edit.SelectCurrentWord Ctrl + W
File.ViewInBrowser Ctrl + Shift + W

Also, my extension has the same selection behaviour as Ctrl + D, while copying/cutting the example you provided, so it will not work for you either.

What you need, in fact, is a new Select Word algorithm (probably extracted from VS2019), which appears to recognise only letters, numbers and underscore as valid word characters. Maybe a few other symbols/combinations...

Hope this helps

alefragnani commented 4 years ago

It appears your request has also been made in VS Code itself. I think these issues can help a bit more, using the wordSeparator setting...

wasker commented 4 years ago

Thanks for the pointers!

I was referring to Edit.SelectCurrentWord behavior. It does look like VSCode needs to have separate functionality. I'll file an issue there.

wasker commented 4 years ago

Available for all in 1.44.