在 Visual Studio Code 中关闭整行复制 [英] Turn Off Whole Line Copy in Visual Studio Code
问题描述
我正在尝试在 Visual Studio Code 中禁用该功能,如果您没有突出显示选择,则 ctrl+c 复制整行.我从来没有故意这样做过,但是当我按 ctrl+c 而不是 ctrl+v 时,我总是不小心这样做.
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:
在File->Preferences->Keyboard Shortcuts下,有默认设置:
Under File->Preferences->Keyboard Shortcuts, there is the default setting:
{ "key": "ctrl+c", "command": "editor.action.clipboardCopyAction",
"when": "editorTextFocus" },
我已尝试更改此设置,以便仅在选择某些内容时进行复制,方法是将以下内容放入我的 keybindings.json 文件中:
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" }
我认为这应该在将复制操作重新绑定到仅在实际选择某些内容时才起作用之前清除先前的绑定.但是,它不起作用.当没有选择任何内容时,编辑器仍会复制整行.如果我只有第一行,它会成功地完全删除绑定,所以我知道它正在做一些事情,但是when"标签似乎没有按应有的方式运行.
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?
推荐答案
在设置中输入以下行:
"editor.emptySelectionClipboard": false
这应该完全符合您的要求.
That should do exactly what you want.
这篇关于在 Visual Studio Code 中关闭整行复制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!