Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change `editor.action.smartSelect.grow` to not treat camelCase words as boundaries?

If I have a variable called helloWorld, and I put my cursor somewhere in World, and run editor.action.smartSelect.grow, it'll just select "World". Is there a setting to make it select the entire variable, helloWorld? I want it to behave more like IntelliJ.

like image 931
mpen Avatar asked Oct 18 '25 19:10

mpen


2 Answers

Just disable the following setting: "Editor > Smart Select: Select Subwords".

like image 145
Alex Avatar answered Oct 21 '25 06:10

Alex


You can achieve that by one of the following commands.

editor.action.smartSelect.expand
editor.action.smartSelect.grow (obsolete)

[edit: Obsolete, vscode has camelCase navigation/smartSelection since v1.25]

An important prerequisite is to have the feature of camel case navigation enabled. For some inexplicable reason, VS Code doesn't come with it by default and requires one to install an extension for it.

My suggestion for camelizaton is Camel Case Navigation from Maptz, which can be installed from the GUI or by the command below. Try out your camel humping by ctrl+left and ctrl+right to verify the functionality.

code --install-extension maptz.camelcasenavigation

I've mapped the expansion and shrinkage in my settings.json the following way.

{ "key": "ctrl+alt+right", 
  "command": "editor.action.smartSelect.expand", 
  "when": "editorTextFocus" },
{ "key": "ctrl+alt+left", 
  "command": "editor.action.smartSelect.shrink", 
  "when": "editorTextFocus" }, ...

I've been told on occasion that some people experienced that functionality to be distorted, though. Unable to confirm that, we speculated that it was due to an unfortunate combination of expansions and plugins, possibly colliding somehow. May that be the case in your editor?

like image 36
Konrad Viltersten Avatar answered Oct 21 '25 07:10

Konrad Viltersten



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!