Peter Brownstein / Digital Marketing / October 21st, 2008

VS 2008 – Apply Cut or Copy Commands to blank lines when there is no selection

Have you ever copied some code in order to place it on a new line, and then when you tried to paste it you hit CTRL-C instead of CTRL-V?  If you have, then you probably have dealt with the frustration of losing what was in your clipboard.  For most people this meant finding that code to once again copy it and then meticulously stare at the keyboard making sure that they hit the right key.

Well, there is one way to deal with this and that is using CTRL-SHIFT-V.  This shortcut key will allow you to cycle through your clipboard and get back that code you just lost.  If you hold CTRL-SHIFT while hitting ‘V’ you will begin to cycle through each element in your clipboard, probably starting with the new empty line you copied and then followed by the code you had intended to paste.  This is actually a very handy shortcut key that I also find useful outside of this scenario.

For those of you who would rather not deal with ever losing your clipboard to a blank line, well there is an option for you too.  If you go to Tools > Options > Text Editor > All Language > General you can uncheck “Apply Cut or Copy Commands to blank lines when there is no selection”.  From here, you will no longer have to deal with the unfortunate mistype of copying a blank line.

I recently came across this and many other great tips at Sara Ford’s Blog.  Within it you can find Visual Studio 2008 tips, which she publishes daily.  I would recommend to anyone using Visual Studio to definitely add this to their list of RSS Feeds if they have not done so already.