Cut or Delete the Current Line


Keyboard:  CTRL + L (cut text); SHIFT + DEL(cut text and carriage return); CTRL + X(cut text and carriage return); CTRL + SHIFT + L (delete)
Command:  Edit.LineCut; Edit.Cut; Edit.Cut; Edit.LineDelete
Versions:  2008,2010
Published:  4/4/2010
Code:  vstipEdit0038

 

You can quickly and easily do a cut operation by doing the following:

  1. Place your cursor on any line:
    image
  2. Do one of the following commands:
    1. CTRL + L to cut the text only
    2. SHIFT + DEL or CTRL + X to cut the line and the carriage return at the end of the line

If you want to DELETE the line instead you can use CTRL + SHIFT + L

Comments (10)

  1. ccatto says:

    Hey Now Zain,

    Never tried Ctrl + L for Line & Ctrl + Shift + L for del Line before today.

    Thx 4 the info,

    Catto

  2. zainnab says:

    Catto!

    So…do you like the keystrokes?  How are they working for you?

    Z

  3. Thomas says:

    Hi,

    I do not see any difference between CTRL + L and CTRL + X Im my VS2008 both cut the whole line including the carriage return.

    And I’d really wish that CTRL + X (and even more CTRL + C) would do nothing, if no text ist selected. Countless times I lost text in the clipboard because I accidently pressed CTRL + C instead of CTRL + V (Paste).

    Thanks for your daily tips, they rock!

    Thomas

  4. Jonas says:

    @Thomas for your copy empty text problem there is a setting you can change to avoid it. Tools -> Options -> Text Editor -> All Languages -> General -> unselect "Apply cut and Copy Command to empty lines" Also the your previous copied content arent lost you can find the lates (20) by pressing ctrl + shift + V.

  5. zainnab says:

    Good catch Jonas, this one totally got by me.  The tips for that can be found here:  blogs.msdn.com/…/how-to-keep-from-accidentally-copying-a-blank-line.aspx

  6. Paul says:

    I have been waiting for the equivalent of VB6's Ctrl-Y for years!  Thanks a lot!  Are you updating the book for VS 2012 anytime soon? 😛

  7. zainnab says:

    Hey Paul 🙂

    Yeah Sara and I are hasing out what we want to put in the new book and some changes we want to make.  You can see what we are currently thinking about here:

    blogs.msdn.com/…/coding-faster-v2-being-considered.aspx

    Z

  8. Paul says:

    Excellent, Z.  I'll keep an eye on that development.

  9. amersaw@hotmail.com says:

    @Thomas you can use Ctrl+Shift+V to roll back in the clipboard to earlier values that you copied in Visual Studio, it rescued for me many codes that I would lost without it.

  10. dchne says:

    As Emacs user I save file with Ctrl+x+s, so what happens in VS is that one random line of code is mysteriously deleted before saving

Skip to main content