I am working on OS Ubuntu 22.04 running inside a Virtualbox VM hosted in a windows 10 OS.
Inside the VM, it seems that my VScode has reset some of the user-defined keyboard shortcuts I have previously set.
So I want to re-define them.
I want to change the keyboard shortcut of "Toggle Line Comment", which is set from CTRL + Y to CTRL + ù ( currently CTRL + Y is assigned by the system to "redo", and that is OK ).
So I click on the pencil icon of "Toggle Line Comment",
press the keys combination CTRL + ù
"ù" gets interpreted as "[Backslash]"
press enter
but then I still see assigned CTRL + Y (as if the change was rejected); and from some tests I did, that one is the only combination that manages to toggle comment lines.
I have tryed to restart VScode but nothing changes, I cannot edit the settings from the UI.
So I have tryed to edit them from the keybindings.json
tommaso@tommaso-VirtualBox02:~$ sudo locate keybindings.json
/home/tommaso/.config/Code/User/keybindings.json
tommaso@tommaso-VirtualBox02:~$ vim /home/tommaso/.config/Code/User/keybindings.json
And the content of the opened file is
[
{
"key": "ctrl+alt+[Backslash]",
"command": "editor.action.blockComment",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+shift+a",
"command": "-editor.action.blockComment",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+shift+7",
"command": "-editor.action.commentLine",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+[Backslash]",
"command": "editor.action.commentLine"
}
]
It is indeed strange that the last {}
entry I have added via the UI is missing the "when"
key.
Anyway I have edited the content to
[
{
"key": "ctrl+alt+[Backslash]",
"command": "editor.action.blockComment",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+shift+a",
"command": "-editor.action.blockComment",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+shift+7",
"command": "-editor.action.commentLine",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+[Backslash]",
"command": "editor.action.commentLine",
"when": "editorTextFocus && !editorReadonly"
}
]
saved,
restarted VScode
but again, the "toggle line comment" gets activated only by CTRL + Y.
The strange thing is that the CTRL + ALT + ù, that is
{
"key": "ctrl+alt+[Backslash]",
"command": "editor.action.blockComment",
"when": "editorTextFocus && !editorReadonly"
}
works fine.
It is like VS code cannot load changes from keybindings.json .
What can be blocking the edit?