Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Visual-Studio

Prevent Cutting or Copying Blank Lines in Visual Studio

5.00/5 (1 vote)
28 Jun 2012CPOL 13.6K  
How to prevent cutting or copying blank lines in Visual Studio

Introduction

I hope you know that we are not required to select a line to cut or copy it in Visual Studio, you can just keep the caret in a line and press Ctrl + C or Ctrl + X and the text in the line will be copied to your clipboard and you can insert this line anywhere in your code by pressing Ctrl + V.

It will also copy a blank line, but people use Ctrl + X command to delete blank lines and some may find this as an issue as they didn’t intend to copy the blank line and also it will clear the previously copied item in the clipboard.

It is surprising as usual to find that Visual Studio team has thought this out and provided a setting which prevents the copying of blank lines, and Cut command will just delete the blank lines.

I found this when I recently bumped into the setting in Visual Studio, in Text Editor > All Languages called "Apply Cut or Copy commands to blank lines when there is no selection".

preventblanklinecopying

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)