Visual Studio (2005,2008,2010) Tips and Tricks.
#46 Cut/Move/Delete Current line in the Visual Studio editor
Tuesday, February 10 2009
Do you recognize this sequence?
Home.
Shift.
Up or Down.
[CTRL]+[X] or [Delete]
There are many better ways to cut or delete your current line of code/markeup/css/xaml/whatever. This Video Trick shows you how.
Snippets / Notes:
This work is licensed under a Creative Commons license.
Visual Studio Tip / Trick #046 English Transcription:
Today’s Visual studio video trick of the day is trick No. 46 which is a repost of Sara Ford’s original trick 46 back on September of 2007. The trick binding is [CTRL]+[L] which will cut and move the current line to your clipboard, so now I can [CTRL]+[V] and paste that line. There is another trick here which is [CTRL]+[SHIFT]+[L] which is just delete current line, that does not move it to the clipboard so [CTRL]+[V] to paste is still going to use that last line.
Incidentally there is also [SHIFT]+[DELETE] have you don’t have anything selected on the line, [SHIFT]+[DELETE] will move that line to your clipboard. So [SHIFT]+[DELETE] then you can paste that some where else. If you do have some thing selected then [SHIFT]+[DELETE] will just delete that line or just delete what you have selected and move that to the clipboard.
And then a third way of doing the same thing is [CTRL]+[X] for your standard copy and paste. If you don’t have any thing selected on a line [CTRL]+[X] will infact delete that line and move that entire selection to your clipboard. So there are three different ways to accomplish this same thing [CTRL]+[L], [CTRL]+[SHIFT]+[L] then [SHIFT]+[DELETE] and [CTRL]+[X]. I believe the multiple versions of these keys strokes being bound to the same thing has to do with how you setup your original profile whether its C# or Visual Basic or one of the other profiles that are out there. So if you really want to get to the bottom of, you can look under tools, options, keyboard and like we have done many many times look to they keyboard shortcut to find what the bindings are in what environment. We will see ya on trick No.47
1 comment(s)
Thanks for this; just what I was looking for.
Also handy to know how to look up current hotkey assignment.
I tried to find the line cuttting feature it via Tools/Customize..., tab Command, and failed, because it didn't occur to me to scroll down to 'L', for, e.g. 'Line Cut'.
A simple filtering search in such dialogs is sorely needed IMHO.