Reputation: 535
In vscode, ctrl + arrow will not stop at an underscore. Is there any way to change this behaviour, or is there a shortcut to select characters between two underscores?
(I have searched through available shortcuts and extensions but could not find any)
Thanks!
Upvotes: 28
Views: 5417
Reputation: 181639
If you add the underscore to your wordSeparators in the setting Editor: Word Separators
, then
Ctrl+rightArrow : move to the next word separator,
followed by another rightArrow to move after that underscore
, then
Ctrl+Shift+rightArrow will select all word characters up to the next word separator, which might or might not be the next underscore
- depends on your code.
Upvotes: 45
Reputation: 28703
You can use the extension Select By.
With a regular expression you can specify what you recognize as a word separator. Use the moveby.regex
command. And then redefine the key binding for Ctrl+ArrowRight
To select some text based on regular expressions use command selectby.regex
:
Add to your settings.json
"selectby.regexes": {
"selectUnderscores": {
"surround": "_[^_]*_"
}
}
And define a keybinding:
{
"key": "ctrl+f10", // or any other key combo
"when": "editorTextFocus",
"command": "selectby.regex",
"args": ["selectUnderscores"]
}
Upvotes: 3