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

Viewed 396

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.

1 Answers

You can achieve that by one of the following commands.

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

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?

Related