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

70,775

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.

Tools | Options | Keyboard

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)

Share:
70,775

Related videos on Youtube

Petr Synek
Author by

Petr Synek

I am a software developer currently working for an actuarial consulting firm in Seattle.

Updated on December 25, 2021

Comments

  • Petr Synek
    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
    Petr Synek over 13 years
    LineDelete! Why did they have to name it backwards! It looks like in VS2010 it is bound by default to Ctrl + Shift + L, though.
  • griegs
    griegs over 13 years
    Yeah 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
    Sasha Chedygov over 13 years
    I personally have this set as Ctrl + E to make it easier to use.
  • griegs
    griegs over 13 years
    Ctrl + E? I'd be more inclined to keep the xcv and make it shift + x just thinking about it.
  • Sasha Chedygov
    Sasha Chedygov over 13 years
    @griegs: Shift + X? Then how do you make a capital X?
  • griegs
    griegs over 13 years
    LOL, Oh yeah, oops. Never liked captial x anyway!
  • Kirk Woll
    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
    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
    Sasha Chedygov over 13 years
    @JChristian: Fair enough. :) They definitely could've made that interface a lot more user-friendly.
  • Kirk Woll
    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
    Imad Nabil Alnatsheh over 6 years
    it's Ctrl + D for me, a habit I picked up from Elipse
  • Colonel Panic
    Colonel Panic over 6 years
    Alas 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
    user1068352 about 5 years
    Shift + Del worked for me in VS 2015 with ReSharper
  • Stephen
    Stephen almost 5 years
    Glad 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
    surfmuggle about 3 years
    Visual Studio Code 1.39.2 under Windows has the same shortcut Shift + Ctrl + k
  • DAG
    DAG about 3 years
    OH, thank you for pointing out SHIFT isn't necessary
  • tiny_mike
    tiny_mike over 2 years
    SHIFT 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
    porg over 2 years
    Thanks 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.