visual-studio 有没有办法在 Visual Studio 中删除一行而不剪切它?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3731968/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there a way to delete a line in Visual Studio without cutting it?
提问by JChristian
I want to delete a line just like hitting Ctrl+ Xwithout anything selected, but without saving the line to the copy stack. Is this possible?
我想删除一行,就像在没有选择任何内容的情况下点击Ctrl+一样X,但不将该行保存到复制堆栈中。这可能吗?
I'm using Visual Studio 2010.
我正在使用 Visual Studio 2010。
回答by Kirk Woll
Edit.LineDeleteis the name of the command. By default it's bound to Ctrl+ Shift+ L, but you can give it whatever you like in Tools | Options | Keyboard.
Edit.LineDelete是命令的名称。默认情况下,它必然Ctrl+ Shift+ L,但你可以给它任何你喜欢的工具| 选项 | 键盘。
Edit: Corrected default shortcut info.
编辑:更正了默认快捷方式信息。
回答by griegs
Ctrl+ Shift+ Lwill delete the line and not copy to the clipboard.
Ctrl+ Shift+L将删除该行,而不是复制到剪贴板。
回答by AMissico
I mapped Ctrl+ L(Global) to Edit.LineDelete. Otherwise, the shortcut key is Ctrl+ Shift+ L, which is awkward. Go to Tools > Options > Environment > Keyboardas shown below.
我将Ctrl+ L(Global)映射到Edit.LineDelete. 否则,快捷键是Ctrl+ Shift+ L,很别扭。进入Tools > Options > Environment > Keyboard如下图所示。


回答by A_01
Correction in my answer
更正我的答案
Ubuntu 16& Visual studio Version: 1.30.1
Ubuntu 16和 Visual Studio 版本:1.30.1
To cut line Shift+ del
剪线 Shift+del
To delete line Shift+ Ctrl+ k
删除行Shift+ Ctrl+k
回答by jitendrapurohit
Its Cmd+ Shift+ Kon mac by default.
它Cmd+ Shift+K默认情况下启用MAC。
But it can be modified according to user needs from the settings (Preferences -> Keyboard Shortcuts) -> search for Delete Linekey value.
但可以根据用户需要从设置( Preferences -> Keyboard Shortcuts) -> 搜索Delete Line键值进行修改。
回答by Patapoom
All the answers were helpful but didn't seem to work for me.
所有的答案都有帮助,但似乎对我不起作用。
So I found the solution --> for Visual Studio 2017 (and certainly 2019):
所以我找到了解决方案 --> 适用于 Visual Studio 2017(当然还有 2019):
Tools > Options > Environment > Keyboard > on the right pane select Edit.LineEdit.
工具 > 选项 > 环境 > 键盘 > 在右侧窗格中选择Edit.LineEdit。
Below there is a ComboBox Use new shortcut in:with Globalwritten --> Change it to Text Editor.
下面有一个 ComboBox Use new shortcut in:with Globalwritten--> Change it to Text Editor。
On the right there is a Text input Press shortcut keys:, so use the shortcut of your choice.
右侧有一个文本输入按快捷键:,因此请使用您选择的快捷键。
Then click on Assign PushButton on the right (otherwise it won't be applied).
然后单击右侧的分配按钮(否则将不会应用)。
Finally > OK.
最后 > 好。
You can now open a .CPP file and use your shortcut to remove a line.
您现在可以打开 .CPP 文件并使用快捷方式删除一行。
回答by Shahzad Latif
On Visual Studio 2019 for Mac, it's CTRL + K to cut the whole line by default.
在 Visual Studio 2019 for Mac 上,默认情况下是 CTRL + K 剪切整行。

