How to prevent copying nothing to clipboard in VisualStudio2015? - visual-studio

This is a super annoying thing with Visual Studio 2015 where if I have a segment of code copied to my clip board and I got to paste it on an empty line but instead make the mistake of pressing Ctrl + C then it erases my copied code and attaches a blank line to the clipboard. Is there a way of preventing this? I'm assuming no but I figured I'd ask to make sure.

May be you are looking for this one-
Goto Tools > Options > Text Editor > All Languages > and uncheck 'Apply Cut or Copy Commands to blank lines when there is no selection' option like below-

Related

Change variable name in multiple lines in visual studio

So, I have some code for a Rect variable mageSection:
And I'd like to copy the same code for a different variable warriorSection. To achieve this:
So I'd like to know if there is a visual studio shortcut for allow you to change variable name in multiple line in visual studio without refactoring the whole variable name.i.e. I don't have to manually change those names from mageSection to warriorSectionfor these 4 lines.
It is a question about shortcut in visual studio rather than writing functions, as I'd like to know the shortcut for this. Many thanks!
Copy and paste the section of code.
Now select the pasted code and hit Ctrl-H to bring up the Quick Replace dialog.
In the top box, type "mageSection".
In the bottom box, type "warriorSection".
Hit Enter and it will find the first occurrence and replace it.
Hit Enter three more times...done.
If I'm understanding your question correctly you should be able to hold down alt while clicking into multiple lines and change them all at once. Then hit ESC to exit multiline editing.

Visual Studio 2013 Ultimate: Caret goes to wherever the mouse clicked

my VS2013 is configured at C# layout. Whenever I click an empty space in a file, say somewhere far right to a line of code that has ended well before, the caret moves where I click and spaces are inserted between the last character of the current line and the caret, regardless the fact that the indent settings are at "Keep tabs".
This is annoying to me. Could anyone tell me how to fix this? When I click an empty space after a line, I expect the caret goes to the right of the last character of the line.
Sounds like Virtual Space. Turn it off using Tools -> Options -> Text Editor -> All Languages (or your chosen language) and uncheck Enable Virtual Space.

How to automatically keep the smart indent in visual studio

I don't quite know how to phrase this question, but basically what happens is:
if i smart indent in visual studio, then click somewhere else on the page or even on the exact same line that has the smart indent, it then goes away, as if I'd had no indenting at all, not even block indenting.
It just puts the cursor/insertion point at the very beginning of the line.
EDIT: BTW I recently formatted my computer and I'm almost certain this wasn't the case before, I'm guessing it's a setting, but I've been fiddling around with all the settings trying to change this, but I can't.
Open Tools->Options. Navigate to Text Editor on the LHS. Select the source type (C++, VB, etc.). Open the tree view node and select Tabs. There, on the RHS you'll find your option

Turn Off Whole Line Copy in Visual Studio

There is a setting in Visual Studio 2010 to turn off copy and cut commands when the cursor is on a blank line and there is no selection. However, when the cursor is not on a blank line and you press ctrl+C, it always copies the entire line to the clipboard. I find this very irritating because I always highlight something first, copy it, then place the cursor where I want to paste it and press ctrl+V. However, sometimes I miss the v and hit the c, which replaces the text on the clipboard with the text of the current line and I have to start all over...
Does anyone know how to turn off copying when there is no selection, regardless of whether the cursor is on a blank line or not?
There is the option in the settings:
Go to Tools - Options -> Text Editor -> ALl Languages -> Apply Cut or Copy commands to blank lines when there is no selection
Also if you accidentally copied something into clipboard you can use following shortcut:
Ctrl+Shift+V – cycle through the clipboard ring.
EDITED:
It seems there is no option to turn of it because by default Ctrl-C is assigned to Edit.Copy command, which copies the current line if nothing is selected. However you can assign following macro to Ctrl-C and it should fix the issue:
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
I know this is old question, but as Macros are no longer natively supported in newer versions of Visual Studio, I thought I'd shared my new extension (cause I couldn't find any existing extensions): https://marketplace.visualstudio.com/items?itemName=KiwiProductions.CopyOnlySelection

Can you set Visual Studio's "smart indent" to not remove tabs in blank lines?

When Visual Studio (2005) has Options -> Text Editor -> C/C++ -> Tabs -> Indenting set to Smart it will automatically indent code blocks and line up squiggly brackets, {}, as expected. However, if you hit enter inside a code block, move the cursor to another line, and then move it back, the inserted tabs are gone and the cursor is positioned all the way to the left. Is there a way to set Visual Studio to keep these tabs?
As far as I know, the only way to do that is to enter something (anything) on that line, then delete it. Or hit space and you'll never see it there until you return to that line.
Once VS determines that you've edited a line of text, it won't automatically modify it for you (at least, not in that way that you've described).
This is an annoyance to myself as well. Anytime the code is reformatted the blank lines are de-tabbed.
You might look at this: http://visualstudiogallery.msdn.microsoft.com/ac4d4d6b-b017-4a42-8f72-55f0ffe850d7 it's not exactly a solution but a step in the right direction

Resources