I'm trying to disable the function in Visual Studio Code where if you don't have a selection highlighted, ctrl+c copies the entire line. I have never tried to do this on purpose, but I am always doing it accidentally when I hit ctrl+c instead of ctrl+v.
Here's what I have tried, which seems like it should work:
Under File->Preferences->Keyboard Shortcuts, there is the default setting:
{ "key": "ctrl+c", "command": "editor.action.clipboardCopyAction", "when": "editorTextFocus" },
I have attempted to change this, so that it only copies when something is selected, by placing the following in my keybindings.json file:
{ "key": "ctrl+c", "command": "-editor.action.clipboardCopyAction"}, { "key": "ctrl+c", "command": "editor.action.clipboardCopyAction", "when": "editorHasSelection" }
I think this should clear the previous binding before re-binding the copy action to only function when something is actually selected. HOWEVER, it doesn't work. The editor still copies a whole line when nothing is selected. If I only have the first line in there, it successfully removes the binding completely, so I know it's doing something, but the "when" tag doesn't seem to be functioning the way it should.
Is there any way to get the editor to do what I want?
In Settings enter the following line:
"editor.emptySelectionClipboard": false
That should do exactly what you want.
Because this comes up on Google as a popular answer...
FYI this is also now a setting in the Settings GUI, search the settings for "empty selection" and it'll narrow it down. Untick to disable and praise your chosen deity.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With