@mbylst Iâve been looking for the same thing - a single-key shortcut to quickly disable the mighty cursor tab when itâs doing too much and starts editing the code around the cursor when Iâm just trying to fix some indentations.
Since I couldnât find anything online, I tried to come up with my own solution. Maybe itâs not the most elegant way to do it, but I tied so many different things and this was the only thing that actually worked in the end.
Hereâs the setup:
First we need extensions, so hit Ctrl+Shift+X and in the marketplace find and install these two:
âSettings Cyclerâ by hoovercj
âmulti-commandâ by ryuta46
A couple lines of code in the user settings.json and keybindings.json.
settings.json:
{
// ... other settings ...
"cursor.cmdk.useThemedDiffBackground": true,
"settings.cycle": [
{
"id": "toggleCursorTabSet_disable",
"values": [{
"cursor.cmdk.useThemedDiffBackground": false,
"editor.cursorStyle": "line-thin"
}]
},
{
"id": "toggleCursorTabSet_enable",
"values": [{
"cursor.cmdk.useThemedDiffBackground": true,
"editor.cursorStyle": "line"
}]
}
],
"multiCommand.commands": [
{
"command": "multiCommand.toggleCursorTabEnable",
"sequence": [
"editor.action.enableCppGlobally",
"settings.cycle.toggleCursorTabSet_enable"
]
},
{
"command": "multiCommand.toggleCursorTabDisable",
"sequence": [
"editor.cpp.disableenabled",
"settings.cycle.toggleCursorTabSet_disable"
]
}
]
}
keybindings.json:
[
// ... other keybindings ...
// this is optional : removes the default keybinding for ctrl+tab
{
"key": "ctrl+tab",
"command": "-workbench.action.quickOpenPreviousRecentlyUsedEditorInGroup",
"when": "!activeEditorGroupEmpty"
},
// cursor tab toggle keybindings
{
"key": "ctrl+tab",
"command": "multiCommand.toggleCursorTabEnable",
"when": "!config.cursor.cmdk.useThemedDiffBackground"
},
{
"key": "ctrl+tab",
"command": "multiCommand.toggleCursorTabDisable",
"when": "config.cursor.cmdk.useThemedDiffBackground"
}
]
Donât forget to remove any other keybindings for âCtrl+Tabâ or choose an alternative shortcut that isnât already in used.
That should do the trick!
By the way, I chose the âcursor.cmdk.useThemedDiffBackgroundâ setting to store the toggle state, as it doesnât seem to have much impact anyway. Itâs a bit messy, but hey⌠it works! You could also replace it with a different boolean key-value in settings.json. Itâs necessary for the when-condition in the keybindings.