Is there a way to delete a line in Visual Studio without cutting it?
Solution 1
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.
Solution 2
Ctrl + Shift + L will delete the line and not copy to the clipboard.
Solution 3
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.
Solution 4
Correction in my answer
Ubuntu 16 & Visual studio Version: 1.30.1
To cut line Shift + del
To delete line Shift + Ctrl + k
Solution 5
CTRL + L (Visual Studio 2019 Windows)
Related videos on Youtube
Petr Synek
I am a software developer currently working for an actuarial consulting firm in Seattle.
Updated on December 25, 2021Comments
-
Petr Synek over 2 years
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'm using Visual Studio 2010.
-
Petr Synek over 13 yearsLineDelete! Why did they have to name it backwards! It looks like in VS2010 it is bound by default to
Ctrl + Shift + L
, though. -
griegs over 13 yearsYeah but it's less than useful. I'd be mapping Delete + Shift or Ctrl to do the same rather then having to press three keys.
-
Sasha Chedygov over 13 yearsI personally have this set as Ctrl + E to make it easier to use.
-
griegs over 13 yearsCtrl + E? I'd be more inclined to keep the xcv and make it shift + x just thinking about it.
-
Sasha Chedygov over 13 years@griegs: Shift + X? Then how do you make a capital X?
-
griegs over 13 yearsLOL, Oh yeah, oops. Never liked captial x anyway!
-
Kirk Woll over 13 years@musicfreak, when I first sought this command, I typed "Line.Delete" and looked for what was there (this command is omitted when you search in that fashion). The terrible UI only allows me to see 4 results at a time (for me, contrary to that screen shot in the other answer.) which makes it a real pain.
-
Petr Synek over 13 years@musicfreak, I did search for "line" and "delete". But with so many results returned from those searches, it makes it very difficult to locate.
-
Sasha Chedygov over 13 years@JChristian: Fair enough. :) They definitely could've made that interface a lot more user-friendly.
-
Kirk Woll over 13 years@nathan_hc, that actually performs a cut, which pollutes the clipboard. (Try it yourself and paste after using CTRL-L)
-
Imad Nabil Alnatsheh over 6 yearsit's Ctrl + D for me, a habit I picked up from Elipse
-
Colonel Panic over 6 yearsAlas this doesn't work as expected when word wrap is enabled. Please vote for the bug report at developercommunity.visualstudio.com/content/problem/138259/…
-
user1068352 about 5 yearsShift + Del worked for me in VS 2015 with ReSharper
-
Stephen almost 5 yearsGlad to learn this, never needed this feature so much until today, now I wonder how I ever lived without it (and polluted my clipboard) for all those years...
-
surfmuggle about 3 yearsVisual Studio Code 1.39.2 under Windows has the same shortcut
Shift
+Ctrl
+k
-
DAG about 3 yearsOH, thank you for pointing out SHIFT isn't necessary
-
tiny_mike over 2 yearsSHIFT is absolutely necessary if you want to be able to remove the line without cutting. CTRL + L does the same as CTRL + X or SHIFT + DEL. To be able to remove a line without copying it you need to use CTRL + SHIFT + L.
-
porg over 2 yearsThanks for the hint!
Cmd
+Shift
+K
👍 deletes the line and the cursor will then be at the same position as it was on the deleted line but on the line that gets sucked up. Or if that line is shorter than at the end of that line. Great!Cmd
+L
👎 on the Mac on the other hand selects the current line and puts the cursor at the start of the next line. So when overwriting your cursor will insert before the whitespace indentation of the next line. Most of the time not what you want.