Delete a line in Visual Studio without copying it?
Solution 1
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.
Solution 2
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
Solution 3
Ctrl + Shift + K
will work fine for both Windows and Linux.
Solution 4
Go to tools -> options. Tab Environment -> subtab Keyboard.
Select Edit.LineDelete. Assign a shortcut. Thats it. I use Alt + D.
Solution 5
Default Shortcut Key in VS Code is : Ctrl + Shift + K.
Related videos on Youtube
BrunoLM
I'm a Developer for Fun! Things I like Code Play games Anime / Manga Contact information [email protected] LinkedIn Facebook Site - https://brunolm.github.io/ Blog - http://blog.codingwise.com/
Updated on September 17, 2022Comments
-
BrunoLM over 1 year
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?
-
ChrisF over 13 yearsWhich version of Visual Studio are you using? Because
Del
on highlighted lines works for Visual Studio 2008. I wouldn't have posted my answer if I hadn't tested it first. -
ChrisF over 13 yearsAlso what keyboard mapping scheme are you using?
-
ChrisF over 13 years@T. Kaltnekar - he should have explained that in the question or as a comment on the answer, we're not all mind readers!
-
T. Kaltnekar over 13 yearsWell, he did state he's looking for a shortcut which would suggest a key combination. I usually just go to start of line, pres Shift+Down then Del. Didn't even know there's a combo for directly deleting a line. For most simple things I don't use special shortcuts since they usually work in one editor and not in another.
-
-
ChrisF over 13 yearsI did get down-voted for suggesting this very solution.
-
BrunoLM over 13 yearsMy question is not how to delete a line in a text-editor. It is about a shortcut on Visual Studio to delete a line.
-
StackedCrooked over 13 years@BrunoLM: my solution works in Visual Studio
-
ChrisF over 13 yearssee @T. Kaltnekar's comment on the question
-
T. Kaltnekar over 13 years+1 for pointing out where you can find a key combo or add new one.
-
BrunoLM over 13 yearsNot what I asked.
-
Mike Clark about 13 yearsYes, of course this works. But it is too slow! :)
-
gronostaj over 10 yearsSame thing, but one key less: go to line,
Home
,Shift
+Down
,Del
;) -
Samuel over 10 yearsOld school boy :)
-
ᴍᴀᴛᴛ ʙᴀᴋᴇʀ almost 10 yearsThis setting is under Tools>Options as mentioned below
-
Kamil over 9 yearsThis is not keyboard shortcut, this is another "how to play on the piano" answer ;)
-
Cfinley about 9 yearsCan you add in the relevant parts of the link into your answer? We ask this to help the OP out, so they will not have to search through information that may not pertain to them. This is also to preserve the relevant information in case the hosting site goes down. For more information, see this meta post.
-
HankCa over 6 yearsAnd more importantly,
CTRL+SHIFT+L
doesn't copy the line to the buffer (SHIFT + Del
is assigned toCUT
by default). So if you re-assignSHIFT + Del
as the short-cut forEdit.LineDelete
then you can have that nice shortcut with the nasty side-effect. Nice one, thanks! -
mgae2m over 6 yearsWhat is different between
CTRL+L
andCTRL+SHIFT+L
? -
Tetsujin over 5 yearsCan you provide a reference for this. It has already been posited as an answer & has one comment underneath... "No it's not."
-
PeterPan about 5 yearsActually it works just fine on Windows 10 with Visual Studio Code 1.32.3.
-
dawsnap almost 5 yearsAlso worked for me in W10
-
Josh Noe over 4 yearsThis should be a comment.
-
Ravish over 4 yearsYeah, I realized 4 years later too that this should a comment :D, deleting it
-
DAG about 3 yearsmgae2m - CTRL+L is Edit.LineCut while CTRL+SHIFT+L is Edit.LineDelete
-
bwdm almost 3 years
ctrl
+shift
+K
works for me on Linux. -
Ooker over 2 yearsthis answer is outdated. Let's downvote it