Can you configure the Visual Studio Find Options? - visual-studio-2012

Is it possible to get the VS 2012 find dialog to always use Current Document and reset case & whole-word when I press Ctrl+F? Currently it remembers my last options and I often forget to turn them off.
Also it sometimes switches to All open documents on its own which totally throws me off. I haven't yet figured out why or when this happens.
I've searched for registry keys and extensions but so far nothing useful has turned up.

It's not possible to get the dialog or the quick find UI to always choose a specific scope out of the box. During beta of VS 2012, this behavior was implemented where CTRL+F would always set the scope to Current Document and Ctrl+Shift+F would set the scope Entire Solution upon invocation of the commands. A lot of users were unhappy with this behavior, so it was reverted. There are no registry keys that you can set to alter this behavior.
Visual Studio always tries to reuse the last used scope. There are circumstances at which that scope is not available, and that'll cause the IDE to change the scope on you. Let's suppose you do a search in "Current Project", after that you close the entire solution and then invoke the dialog. The scope will have to change to something else.
You probably know about this, but Ctrl+F3 will search for the word that is under the caret and it'll always perform that search with the Whole Word option on in the current document. Perhaps that'll suit your needs.

I've published a Visual Studio "SmartFind" extension to fix this issue.
http://visualstudiogallery.msdn.microsoft.com/015611c4-b357-4672-8977-f3ec92f0b808

Related

Any way to circumvent inbuilt auto save in android studio?

The current Android Studio version has inbuilt auto save. Which means if you close a file, it will automatically save the changes.
This is inconvenient, it means when experimenting with code, all changes need to be noted as there's no option to have a dialog requesting to save changes on closing a tab or the project, as in many other ides.
According to documentation IntelliJ IDEA 15.0 Help/Saving and Reverting Changes:
When does IntelliJ IDEA auto save changed files?
Autosave is initiated by:
Compiling a project, a module or a class
Starting a run/debug configuration
Performing a version control operation such as pull, commit, push, etc.
Closing a file in the editor
Closing a project
Quitting the IDE
.../...
Note that those are optional autosave triggers, and you cannot turn off autosave completely.
These are the auto save settings that can be changed in Android Studio:
TLDR
Is there any work around to circumvent this autosave?
These questions are related, but do not acknowledge that this intended behaviour of the ide and are rather asking for fixes within the ide.
Related:
How to disable Auto Save save in Android Studio
How turn off autosave in Android Studio?
If you want to experiment, use the revert button at the top right. This works especially well if you are using a VCS (like git...) as it will revert to the last committed version. And since commits are still manual, this will soon replace your traditional save.
If you are not using a VCS the point in time to which it reverts is a little more arbitrary, but in my experience it takes a pretty good guess. If that doesn't suffice, you can use the history button next to the revert button, which keeps track of every version IntelliJ saved, and you can then go back to any point in time you like. :)
Android Studio as a software is very much based on the JetBrains software solutions such as IntelliJ (used for Java) and PHPStorm (used for PHP, as its name shows).
As a concept in itself, JetBrains have implemented this feature and as a company believe that it's much more efficient and productive than manual save. Hence, there is no way to disable this behavior or enable any confirmations in Android Studio either.
Taken from JetBrains FAQ for IntelliJ:
Because IntelliJ IDEA has the ability to change so many files simultaneously in large refactoring actions, and change them without ever opening them, single file saves don't make very much sense. In recognition of this, IntelliJ IDEA reserves the right to save any of your files literally whenever it wishes. It's actually quite nice to never have to worry about your file's save statuses, once you get used to it.
Having said that, and encountering this issue myself too as a developer, I agree that it would be a good idea if the Manual Save feature were enabled by the Android Engineers (or JetBrains themselves). After all it is up to the developer to choose whether he needs this feature or not.
To Jetbrain's defence, they have a very good Undo function through their Ctrl + Z shortcut keys, letting the developer go back many steps and find where a certain error has occured.
All IntelliJ based products nowadays save any opened or modified files whenever they wish - read this as "immediately".
I would suggest you give up on trying to disable it (trust me, it's not possible to hack it) and either change your work flow or work on copies of the files.
As background I should mention that I am a plugins author for IntelliJ (with 3 publicly released plugins in the JetBrains repository) and thus have a reasonable understanding of the internal IntelliJ architecture.

Chose a color for a particular method in VS2012

Pretty dumb question I know,
I want to know if there is a way to assign a particular color to a method of my choice in .cs file.
So that i donot even accidently go and write or change anything there.
No, Visual Studio does not support this behavior natively (though someone could write an extension that did it).
Some ideas, though...
My first suggestion is to use version control so that any changes you make can be reviewed and reverted.
My second is, in C# you could use a partial class to keep all the code that should never change in one file and the code you can change in another file. You could even go further and set the readonly flag on the file you never want to change (though check how this affects your source control system).
But use version control either way.

Visual Studio: Undo-redo of replace-action does not scroll editor window

I did some find-and-replace actions in my C++ code with visual studio:
only single find-and-replace actions (did not use “replace all”)
only one file affected (did not change multiple files at the same time)
thus, a very simple case!
Then I wanted to undo these changes. So I pressed ctrl-Z one time. This had the desired effect. The latest change (which was still visible in the current screen) was undone.
But I also wanted to undo the remaining changes. These changes where currently not visible on the screen. So I expected the editor to scroll there when pressing ctrl-Z.
But unfortunately the editor did not scroll to the position of the undo when I pressed ctrl-z.
The undo worked, however. I checked by scrolling to the position manually.
Then I tried it with redo. Same result: Redo worked, but the editor did not scroll to the position of the redo.
Finally I tried if this also happens when I undo-redo other types of changes (not made by the “find and replace” functionality).
Result: Undo-Redo worked correctly and also scrolled correctly!
Thus: It seems only changes by the “find and replace” functionality are affected by this problem.
Did you also have this problem and found a solution?
Please help me!
Regards Gerhard
I am having the same thing happen in Visual Studio Ultimate 2012 (Version 11.0.60610.01 Update 3).
It might sound like it's not that important, but it is really hurting the usability of this otherwise great IDE!
PS I've been using VS since the 90s, I still haven't found anything better. I wish MS would put macros back into VS, even if it's VBA (or Python)

How to force IntelliJ to always search in "Whole Project"

I like to use the Find in Path function CTRL+SHIFT+F, that searches for text strings in several files.
One thing I often run into though, is that I search for something that I know exists in at least one file, I get zero results or I find just some of the files that contain the search term.
Then I realise that the Scope setting in the Find Dialog box has been set to Module or Directory for some reason rather that "Whole project" which is what I almost always want.
What fools me here is that this only seems to happen occasionally - often I'll have the scope set to Whole project like I want to, but sometimes it will be something else.
How does IntelliJ decide which scope to use?
Also, is there some setting that can be used to force IntelliJ to always select "Whole project" as the default?
Just collapse the project tab before: Command + 1 or Alt + 1
The default selection depends on the context which launched the search. If you have the project tab open with a folder/file selected it will search in that folder or the parent of that file.
To search by default just close that panel (this will make the context be the whole project) and press the search shortcut and it will be scope properly.
Not really a solution, but how to avoid using the mouse for this:
When the dialog is open, press Alth before pressing enter. This will cause the scope to be set to Whole project.

System.ComponentModel.Design.ExceptionCollection

I'm using the Ribbon control located on CodePlex, and following the tutorial located here . Once I add the reference, and the proper code in the designer I get this error when I try to view the form:
Exception of type 'System.ComponentModel.Design.ExceptionCollection' was thrown
And I cant figure out what I'm doing wrong. Anyone worked with this control and know how to resolve this issue?
Interesting; I just ran into this same issue with one of my own forms; which is how I found your relevant and recent question.
Here's how I solved it:
Open two instances of Visual Studio. Open the same project in both.
In one instance, goto Debug->Exceptions and enable all the 'Thrown' options to stop at first chance exceptions. This will stop the debugger when the exception is generated.
In the same instance, select Debug->Attach to Process, select devenv.exe.
In the other instance, open the form to cause the exception
With any luck the first instance should stop somewhere that yields a more relevant exception.
In my case it turned out to be something that I should have conditioned with:
if (!DesignMode)
{
// Do something that should only happen at runtime
}
Don't forget turn turn off all those 'Thrown' options later.
A workaround for me was:
Right-click on the form and 'View Code'
Keep the code loaded in the editor and then attempt to view the designer again.
This feels very glitchy and I cannot confirm whether it's a problem with my code (as I'm working on an entirely new codebase) or whether it's a VS2012 bug. If I find out, I will report back.
Since the solution outlined by pilotcam didn't work for me, I took a different approach:
Make a SVN commit for the file.
Open the “*.designer.cs” file of the form that shows the error in source view.
Remove larger blocks of form element declarations.
Fix all compilation errors with ReSharper (i.e. ensure that nothing is red anymore on the side-indicator).
Save the file. No need to compile.
Open the Windows Forms Designer of the form.
If the error still shows up, do a SVN revert to go back to the initial state.
Repeat steps 2 to 7 until the error does not show up anymore.
Now you’ve encircled the erroneous child control that causes the error.
Repeat steps 2 to 7 with a smaller amount of controls you remove, until you have only one control left.
In my case it was a user control inside a group control inside a tab control, so I first identified the tab control, then the group control and then the user control.
You could isolate the user control inside a new form to further investigate. In my case it was rather easy; I put checks for design mode around most of the functions inside my control to ensure the code only gets executed if the control is not in design mode.
This fixed my error.
I had the same issue and none of the above answers solved the problem.
At the end, emptying the "bin" folder and rebuild has worked for me.
Let me add two more cases when such exception can happen, along with when control tries to do something that is not allowed under design mode:
When it's impossible to compile the user control.
When designer code contains multiple similar (or identical) lines with initialization of same controls or properties, this can easily happen on merge.
All that cases produce same extremely meaningful error message, and in this particular two debugging of Visual Studio won't help, so I just ended up with bisecting my designer code.
[ReadOnly(true)]
[Browsable(false)]
Above all properties worked for me

Resources