Home > Net >  How can I turn VSCode's sub word navigation off?
How can I turn VSCode's sub word navigation off?

Time:07-16

In a snake_cased language, I would want to navigate variablewise and not word_wise and also exclude sigils like @, % or / from these stops.

Example:

|$here_she_goes_again; #the pipe marks my cursor position

With one Ctrl Right, I want to land on the space before the semicolon,

$here_she_goes_again|; #the pipe marks my cursor position

then, with a Ctrl Left, I want to return to the beginning of the line.

|$here_she_goes_again; #the pipe marks my cursor position

Somebody got this to work?

CodePudding user response:

You can use the extension Select By and the command moveby.regex

You are able to define a regex to search and bind this to Ctrl Left and another to Ctrl Right

In the key binding you can limit this to a particular languageID.

CodePudding user response:

Put this into your settings.json:

"[javascript]": {
  "editor.wordSeparators": "`~!@#%^&*()-= [{]}\|;:'",.<>/?"
}

Use whatever your language identifier is. I deleted the $ from the default separators to get your example to work for javascript. You can remove the other characters you indicated. The underscore was already not in the default for me. Just make sure those characters are not in the language-specific setting shown above.

  • Related