39

As this question is for the "big" Visual Studio and Resharper, I'd like to see that feature in VS Code too.

Scrolling through the shortcut list for VS Code, I couldn't find it but I'm hoping that it's still there but called something less intuitive than camel, hump or such.

Community
  • 1
  • 1
Konrad Viltersten
  • 36,151
  • 76
  • 250
  • 438
  • is this question about moving the caret left and right? Or is it about selection expansion and contraction? – starball Jul 06 '23 at 22:15
  • @starball It's actually **both**. The concept of camel-humping means that there's a way to schootch over to the next capital letter (as opposed to the next word). Whether I have *SHIFT* pressed (or whatever is the "selection" key on ones system) or not shouldn't matter. Unless you're referring to the expansion/contraction of a selection in both directions (to the next scope, however we may define it), then no, that's not what the OP intended. – Konrad Viltersten Jul 26 '23 at 13:46

5 Answers5

74

As of version 1.25 these commands are built in:

enter image description here

cezn
  • 2,705
  • 11
  • 16
4

I found this extensions to work https://marketplace.visualstudio.com/items?itemName=ow.vscode-subword-navigation

Funny thing is that you need to configure each combination separately:

{
    "key": "alt+left",
    "command": "subwordNavigation.cursorSubwordLeft",
    "when": "editorTextFocus"
},
{
    "key": "alt+right",
    "command": "subwordNavigation.cursorSubwordRight",
    "when": "editorTextFocus"
},
{
    "key": "alt+shift+left",
    "command": "subwordNavigation.cursorSubwordLeftSelect",
    "when": "editorTextFocus"
},
{
    "key": "alt+shift+right",
    "command": "subwordNavigation.cursorSubwordRightSelect",
    "when": "editorTextFocus"
},
{
    "key": "alt+backspace",
    "command": "subwordNavigation.deleteSubwordLeft",
    "when": "editorTextFocus"
},
{
    "key": "alt+delete",
    "command": "subwordNavigation.deleteSubwordRight",
    "when": "editorTextFocus"
}
Krzysztof Kaczor
  • 5,408
  • 7
  • 39
  • 47
  • 1
    @Swaps you need to apply it to `keybindings.json`. The easiest way to access is just to type `shortcuts` in the command search window. – Krzysztof Kaczor Jul 11 '18 at 17:51
  • 3
    This feature is now integrated in the application: no Plugin needed see: https://stackoverflow.com/a/51329169/3757110 – jvoigt Oct 11 '18 at 14:39
4

If for some reasons your bindings are not set here is the JSON to obtain Cezn's shortcuts.

{
    "key": "ctrl+alt+right",
    "command": "cursorWordPartRight",
    "when": "editorTextFocus"
},
{
    "key": "ctrl+alt+shift+right",
    "command": "cursorWordPartRightSelection",
    "when": "editorTextFocus"
},
{
    "key": "ctrl+alt+left",
    "command": "cursorWordPartLeft",
    "when": "editorTextFocus"
},
{
    "key": "ctrl+alt+shift+left",
    "command": "cursorWordPartLeftSelection",
    "when": "editorTextFocus"
}
{
    "key": "ctrl+alt+backspace",
    "command": "deleteWordPartLeft",
    "when": "editorTextFocus && !editorReadonly"
},
{
    "key": "ctrl+alt+delete",
    "command": "deleteWordPartRight",
    "when": "editorTextFocus && !editorReadonly"
}

Be careful with the ctrl+alt+delete one since it conflicts with another popular windows shortcut.

Other interesting bindings are:

{
    "key": "ctrl+n",
    "command": "explorer.newFile",
    "when": "explorerViewletFocus"
},
{
    "key": "ctrl+shift+n",
    "command": "explorer.newFolder",
    "when": "explorerViewletFocus"
}
starball
  • 20,030
  • 7
  • 43
  • 238
2

VSCode 1.80 (June 2023) includes (in VScode Insider today) PR 182571

Add option for smartSelect to ignore subwords

This brings VS Code to parity with other major editors/IDEs (e.g., JetBrains IDEs have the Use "CamelHumps" words option).

editor.smartSelect.selectSubwords

description: Whether subwords (like 'foo' in 'fooBar' or 'foo_bar') should be selected.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Is it as in *built in, out of the box*? – Konrad Viltersten Jun 29 '23 at 21:42
  • @KonradViltersten It is a new setting, directly available (in VSCode Insiders for now) – VonC Jun 29 '23 at 21:45
  • Please advise. I must be missing something. I run version 1.80.1 (12th of July) and I don't get that setting when I filter for *hump* nor *camel*. I also added it manually to the JSON file, copying the line you quoted. Still, nothing - no camelization based humping going on. How do you activate it on your system?! – Konrad Viltersten Jul 26 '23 at 14:01
  • @KonradViltersten It seems to still have an issue, as [reported here](https://github.com/microsoft/vscode/pull/182571#issuecomment-1609955972). – VonC Jul 26 '23 at 14:07
  • Ah, darn... I've found it finally by searching for *smart* (poorly chosen name, given the camels and humps readily available). But checking it gave nothing of use. So yet, it seems that feature still isn't out there for real. IN-not-HO, it's embarrassing that it still isn't implemented properly. Sort of basic functionality... – Konrad Viltersten Jul 26 '23 at 14:11
  • @KonradViltersten this is for selection expansion and contraction- not for moving the caret forward and back. that's why I commented on your question post asking about whether the question is about selection expansion and contraction. – starball Jul 26 '23 at 19:55
  • @starball Thanks for the clarification. I guess it's back to my plugin for humping the camels... Darn... I still can't understand what kind of person decides not to have that option from day 0. Probably someone who's never humped a camel... – Konrad Viltersten Jul 27 '23 at 09:24
1

There is an extension for this: Camel Case Navigation

enter image description here

James Bond
  • 2,229
  • 1
  • 15
  • 26