views:

827

answers:

6

Is there anyway to disable the rather annoying feature that Visual Studio (2008 in my case) has of copying the line (with text on it) the cursor is on when CTRL-C is pressed and no selection is made?

I know of the option to disable copying blank lines. But this is driving me crazy as well.

ETA: I'm not looking to customize the keyboard shortcut.

ETA-II: I am NOT looking for "Tools->Options->Text Editor->All Languages->Apply cut or copy to blank lines...".

+1  A: 

I'm pretty sure the way to do it in 2008 is the same as the way in 2005... check out this tutorial on 'customizing keyboard shortcuts' (about 1/3 of the way down)

http://msdn.microsoft.com/en-us/library/bb245788(VS.80).aspx

devinmoore
Well.. I'm not looking to customize the shortcut. I'm looking to making it stop copying the line the cursor is on.This will allow me to map the shortcut to another combination of keys - but the annoyance will still be there..
erlando
A: 

I don't believe it is possible to do this without some type of 3rd party clip board manager that would prevent you from overwriting the clipboard content with the empty string.

ctrlShiftBryan
+1  A: 

I've the free SlickEdit add-in installed, and its CommandSpy feature shows that Ctrl-C executes Edit.Copy whether you've got text highlighted or not. Therefore I guess the answer to your question is No.

However, I do remember this feature annoying the hell out of me when I first encountered it; now I rely on it and get annoyed when I try the same trick in other programs and nothing happens.

Charles Anderson
I agree, it's a very natural action once you expect it. It wouldn't be too difficult for other applications to adopt a similar way of working.
Jonathan Webb
So this, like ctrl+tab, is another example of how Visual Studio does things "special" (like special ed) and doesn't provide any way of reverting to the normal way... so annoying!
thepaulpage
+7  A: 

The real problem you probably experience is that you go to paste, with CTRL+V. And you accidentally type CTRL+C, and end up overwriting the stuff that's on your clipboard. You can't disable this as far as I know, however, the work around for this, is that you can press CTRL+SHIFT+V multiple times to go back up the stack of things you have copied in visual studio. Not only does this allow you to recover what you originally copied, but you'll also find that CTRL+SHIFT+V very useful in a lot of other situations.

Kibbee
+1  A: 

I got the same problem, at first I thought it was my bad, I thought that i was accidentally typing ctrl-c in place of ctrl v but not, i'm really experiencing problems with these things

=/

Hivort
+3  A: 

If you aren't willing to customize the keyboard settings, then Ctrl-C will always be Edit.Copy, which will copy the current line if nothing is selected. If you aren't willing to use the tools VS provides to customize the interface, then you can't do it.

However, the following works: Assign this macro to Ctrl-C:

Sub CopyOnlyIfSelection()
    Dim s As String = DTE.ActiveDocument.Selection.Text
    Dim n As Integer = Len(s)
    If n > 0 Then
        DTE.ActiveDocument.Selection.Copy()
    End If
End Sub
David Walthall
What a novel approach! I wish I'd thought of that 10 years ago when MS added this goofy 'feature'. Wish I could give you credit for answering... and in VB too!
mattmc3