There is the shortcut Shift+Del to delete a line, but I want to delete the line without modifying what is in the clipboard.
Is there some way to configure it or another shortcut?
By default, if you are using the C# default profile, you can delete a line using Ctrl + Shift + L.
You can customize this using Tools->Customize. Select "Keyboard". Look for the command Edit.LineDelete to assign it to whichever keyboard shortcut you like.
CTRL+SHIFT+L
doesn't copy the line to the buffer (SHIFT + Del
is assigned to CUT
by default). So if you re-assign SHIFT + Del
as the short-cut for Edit.LineDelete
then you can have that nice shortcut with the nasty side-effect. Nice one, thanks!
If you got here looking for an answer for Visual Studio Code the default shortcut is:
ctrl + shift + K for Windows
⌘ + shift + K for MacOS
However, you can change on File > Preferences > Keyboard shortcuts
{
"key": "ctrl+shift+delete",
"command": "editor.action.deleteLines",
"when": "editorTextFocus && !editorReadonly"
}
For Visual Studio answer see @heavyd's answer
Ctrl + Shift + K
will work fine for both Windows and Linux.
Go to tools -> options. Tab Environment -> subtab Keyboard.
Select Edit.LineDelete. Assign a shortcut. Thats it. I use Alt + D.
Default Shortcut Key in VS Code is : Ctrl + Shift + K.
You can install the Productivity Power Tools, which are made by Microsoft, as an extension.
The feature that you might get some use out of is Triple Click, which highlights an entire line when you triple click it. Then you can simply use the Delete key.
The Shortcuts WinForms Control supports the modifier keys, multiple keys shortcuts, and shortcuts without modifier keys to build a keyboard trigger action, such as Ctrl, Alt and Shift with any other keys to trigger a specific action for their Windows applications.
This combination will only delete the line: Ctrl + Shift + L
Source: Cut or Delete the Current Line
I know I am quite late in the party, but, here is a list of Shortcut keys for Visual Studio: http://blogs.msdn.com/b/piyush/archive/2007/03/16/useful-visual-studio-shortcut-keys.aspx
If you often find yourself copying blank lines to the clipboard and erasing the previous clipboard contents, try navigating to Tools->Options->Text Editor->[All Languages or your favorite language]->General and unchecking “Apply Cut or Copy commands to blank lines when there is no selection.”
Or, the old fashioned way (for me it is a habit and I even had to think what was the combination :) ):
Works in most text editors :)
Home
, Shift
+Down
, Del
;)
Commented
Nov 3, 2013 at 11:19
It seems I'm risking a downvote for not providing a single-keystroke solution, but I want to share my solution anyway:
HOME, SHIFT + ARROW-DOWN (repeat for multiple lines), DEL
It's quick and has the added advantage that works in other editors as well.
Del
on highlighted lines works for Visual Studio 2008. I wouldn't have posted my answer if I hadn't tested it first.