Click here to Skip to main content
Click here to Skip to main content

Prevent Cutting or Copying Blank Lines in Visual Studio

By , 28 Jun 2012
 

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)

About the Author

RKT.Ashoka
Technical Lead Aditi Technologies
India India
Member
I am Ashoka (R.K.T.Ashoka), I am a software professional who is passionate about designing and developing software applications. I blog at www.codesmiles.com, I will be writing about .Net, programming, technology, etc

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionCtrl+JmemberSarafian28 Jun '12 - 20:34 
I use the Ctrl+J a lot to delete non-empty lines without selecting them.
But this combination also modifies the clipboard.
I hoped with the option you mentioned that It would get fixed but sadly it didn't.
If you find anything more, i would appreciate it.
AnswerRe: Ctrl+JmemberRKT.Ashoka29 Jun '12 - 2:11 
i am not getting any reaction from Visual studio for Ctrl+J which dev environment settings do you use? is it VC++ ?
GeneralRe: Ctrl+JmemberSarafian29 Jun '12 - 2:30 
Hmmm. Sorry.
C# default
GeneralAlternativememberperilbrain28 Jun '12 - 5:44 
What do you say about this global idea ...
 
Paste data in Notepad++
Press Ctrl+H
Select Search mode to Extended
now in Find what write \r\n\r\n
& In replace with \r\n
Now replace...
Copy the data without blank lines
Wink | ;)
GeneralRe: AlternativememberRKT.Ashoka28 Jun '12 - 6:11 
Hi perilbrain
 
Thanks for reading.. but you see this option is for using ctrl+x or Shift+Del as a short method for deleting the blank lines.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web03 | 2.6.130523.1 | Last Updated 28 Jun 2012
Article Copyright 2012 by RKT.Ashoka
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid