Visual Studio 2013 Avoid Copying Blank Lines – Yes, it is something that happens to me often. I don’t know why I do it so easily. I guess it is because I use the keyboard shortcuts to copy and paste (Ctrl+C and Ctrl+V).
When I want to cut, I type Ctrl+X and then because my finger is moved one key to the left, I type Ctrl+C instead of Ctrl+V. It has been the bane of my Visual Studio experience since Visual Studio 2003 and has infuriated me endlessly (even if that fury is only vented at my own stupidity). But this little pet peeve of mine is particularly troublesome when I am already frustrated with difficult code.
With Visual Studio 2013 we see an option available to avoid this silly mistake (and save some of my sanity).
Visual Studio 2013 Avoid Copying Blank Lines
To enable this feature, head on over to Tools-> Options.
In the search text box type in ‘cut copy’ and the results will filter as you type. This is another awesome enhancement of the Options dialog that I love. No more clicking through endless menu’s to find some setting you used a few weeks ago.
Here you will see that there is an option under ‘All Languages | General’ called ‘Apply Cut or Copy commands to blank lines when there is no selection’. By default it should be checked, which brings me to the question of why anyone would want to copy a blank like to begin with. Deselect that option and your problem is resolved.
Lastly, as pointed out by Zain Naboulsi, deselecting this option will prevent you from using Shift+DEL to delete an empty line. If you simply can’t live without Shift+DEL, you will have to enable this feature.
This functionality is also available in Visual Studio 2012 under the same options menu. Thanks to jphamilton in the comments for the tip.