Is there a way to delete a line in Visual Studio without cutting it?

后端 未结 10 1390
刺人心
刺人心 2021-01-30 05:55

I want to delete a line just like hitting Ctrl + X without anything selected, but without saving the line to the copy stack. Is this possible?

I\'

相关标签:
10条回答
  • 2021-01-30 06:18

    I mapped Ctrl + L (Global) to Edit.LineDelete. Otherwise, the shortcut key is Ctrl + Shift + L, which is awkward. Go to Tools > Options > Environment > Keyboard as shown below.

    Tools | Options | Keyboard

    0 讨论(0)
  • 2021-01-30 06:21

    Correction in my answer

    Ubuntu 16 & Visual studio Version: 1.30.1

    To cut line Shift + del

    To delete line Shift + Ctrl + k

    0 讨论(0)
  • 2021-01-30 06:33

    Edit.LineDelete is 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: Corrected default shortcut info.

    0 讨论(0)
  • 2021-01-30 06:33

    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):

    Tools > Options > Environment > Keyboard > on the right pane select Edit.LineEdit.

    Below there is a ComboBox Use new shortcut in: with Global written --> 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.

    0 讨论(0)
  • 2021-01-30 06:34

    The other answers are specific to Visual Studio, which is what was requested by OP, however if anyone is looking for a more generalized way to do this for most Windows programs, you can also Triple-Click to select any block of text, then just press the Delete key. This works for any Windows text editors or TextBoxes, including password boxes, search boxes, browser web address boxes, etc. For text editors such as Visual Studio, a block of text is typically one line of code. Obviously you can do other things too, such as triple-click to select a line of code, then Ctrl-X, Ctrl-V to cut/paste, etc, or just triple-click and type over it to replace a line.

    0 讨论(0)
  • 2021-01-30 06:35

    none of the above answers worked for me. to delete a line in visual studio code use :shift+del

    0 讨论(0)
提交回复
热议问题