Xamarin Community Studio: Annoying auto–indentation - c#

How do I disable auto-indentation feature/bug? (Xamarin 6.11, Mac)
Note: <CURSOR HERE> designates position of cursor and not actual code.
Here are my steps:
I place my cursor as shown:
I press ENTER:
I type my declaration and jump to beginning hoping to fix indentation:
I press BACKSPACE:
Pressing ENTER again at this point brings me back to step 3.
Please help, it's driving me nuts!
Oh yes, changing indentation in Preferences->Code Formatting->C# ... does not affect the behavior, even with restart.

See: https://forums.xamarin.com/discussion/2509/incorrect-auto-formatting-of-c-code-for-specific-functions
Look down to where it says Text Editor -> Behavior.
There is an option named "Enable on the fly code formatting"; You may want to disable this if you wish to format your own codes.
There is also the Smart Indentation mode in Behavior you might want to turn off.

Related

How to hide Intellisense "based on recent edits" suggestions?

What the title says.
I don't mind them being in the "Error List" because they're only marked as "Messages" so they can easily be filtered, but I'd like to hide the dots in the code.
To turn off the "Based on recent edits" stuff, go to turn off IntelliCode suggestions.
Per the docs:
If you wish to turn it off, choose Tools > Options, IntelliCode General tab, and then switch C# suggestions to Disabled
This will turn off "Based on Recent edits" while still leaving on the other stuff like code styles/autocomplete/etc.
How to hide Intellisense “based on recent edits” suggestions?
If you want to hide such suggestion in Intellisense(show as a dot), you should add this below on the top of every cs file:
#pragma warning disable xxx(suggestion ID)
Or use #pragma warning disable to disable every suggestion.
For an example, I have make a similar sample:
================================================================
And usually to remove that Intellisense Suggestion, you should enter Tools-->Options-->Text Editor-->C#-->Code Style and then find such suggestion message and change its Severity from Suggestion to Refactoring Only. With this, you could remove such Suggestion on Code Editor.
Since I did not know your specific suggestion message(based on recent edits) and the ID and also not sure whether such suggestion are in the Code Style menu, so I suggest you could try my first solution.
Note that: So far, no matter which way you suppress the suggestion, removing dot in the Code Editor will also remove the message in the Error List. They are unified, you cannot suppress the IntelliSense in the Code Editor and save the message in the Error List.
Besides, if you still want this,you could suggest a feature on our User Voice Forum.

How to disable “Press tab to replace highlighted range” message in ReSharper 8?

When I write a method call and open bracket, and then get a tooltip to parameters of method. It's great.
Then I press Ctrl + Space to get a list of possible parameters. The tooltip with method parameters is moved up and an IntelliSence hint is opened down. This is also fine. However, the parameters are covered up by an uninformative message: "Press tab to replace highlighted range". See a figure below:
It's really annoying. How can I disable it?
I reverse engineered the Resharper and found a configuration setting that manages a display of “Press tab to replace highlighted range” tooltip. This parameter is:
<s:Boolean x:Key="/Default/Housekeeping/IntellisenseHousekeeping/HintUsed/#EntryValue">True</s:Boolean>
You could add this line in any configuration file and Resharper will disable the tooltip. I use the “This computer” configuration file:
%AppData%\JetBrains\ReSharper\vAny\GlobalSettingsStorage.DotSettings

Visual Studio Code Review Difference Window

When I was doing C# code reviews at first in VS 2012 I was getting a side by side comparison of the old and new code.
However now I am getting all code in the same window with red lines for old code and green lines for new code.
I cannot find the option to change this back to a difference window.
I know this is a simple issue but any help will be greatly appreciated!
There should be a button on the toolbar like this one that will let you select the 4 different "diff modes".
You can also use the following keyboard shortcuts:
Ctrl+\, Ctrl 1 - Inline
Ctrl+\, Ctrl 2 - Side-by-side
Ctrl+\, Ctrl 3 - Left Only
Ctrl+\, Ctrl 4 - Right Only
to change the view.
Below screenshot will help in setting the option to compare side by side.

VS automatically adds brackets if you press "Tab" after an "else". How can I get it to do that after ANY code block opener?

I just noticed this today and it is amazing! I hate typing out the brackets. But why does this only work for 'else' statements? I want this after namespace, class, struct, enum, for, foreach, while, switch, do, and method headers.
Is there any way to turn this functionality on with a wider scope?
For some of them you hit tab twice to auto complete the block.
try Tools > Options > Text Editor > C# > IntelliSense.
You can use the spacebar to select whatever is highlighted in the IntelliSense popup.
OR
You can just type the next character you would type AFTER having normally finished typing.
For example.
I want to enter:
console.writeline
I just type con.wr(" and the rest auto-fills with the correct spacing.
It gets "Smarter" the more you use it.
Type the word "prop" then hit TAB twice. Watch what happens. Then you can hit tab to switch between the parameters.
Here is a Youtube tutorial on using IntelliSense, there might be more resources in there for you.
http://www.youtube.com/watch?v=k6Q0NR2Z0nc

How to permanently disable region-folding in Visual Studio 2008

Anyone know how to turn off code folding in visual studio 2008? Some of my colleagues love it, but I personally always want to see all the code, and never want code folded out of sight. I'd like a setting that means my copy of Visual Studio never folds #regionsor function bodies.
Edit: I recommend this other answer
Go to the Tools->Options menu.
Go to Text Editor->C#->Advanced. Uncheck "Enter outlining mode when files open".
That will disable all outlining, including regions, for all c# code files.
The accepted answer turns off ALL code folding. If you want to disable #region folding but collapse comments, loops, methods, etc I wrote a plugin that does this for you.
Make #regions suck less (for free):
http://visualstudiogallery.msdn.microsoft.com/0ca60d35-1e02-43b7-bf59-ac7deb9afbca
Auto Expand regions when a file is opened
Optionally prevent regions from being collapsed (but still be able to collapse other code)
Give the #region / #end region lines a smaller, lighter background so they are less noticeable (also an option)
Works in C# and VB (but only in VS 2010/2012, not supported for 2008)
You can also disable region-wrapping on generated code (like when you use the Visual Studio shortcut to auto-implement an interface).
alt text http://dusda.com/files/regionssuck.png
Options / Text Editor / C# / Advanced / Enter outlining mode when files open
It's not permanent, but the keystrokes Ctrl-M Ctrl-L expand the regions in a file
Also, a quick way to toggle expand/collapse of all regions is: CTRL + M + L
I've posted an answer in a related-but-not-duplicate thread that may help some people here. I detailed how to create macros that will deactivate a single unit's #regions by commenting out the #region and #endregion directives, with a companion for reactivating them. With the #regions deactivated the Ctrl+M+O / Collapse to Definitions function does exactly what I want it to. I hope this is useful for someone beside myself.
Shortcut to collapse to definitions except regions
This option seem to be available only in C# and not in C/C++ (Visual Studio 2005). To disable outlining in C/C++ files you need to make a trick by changing the outlining color to editor's background color. To do this go to Tools > Options > Environment > Fonts and Colors > Collapsible Text > Change "Item Foreground" color to White (or whatever your background color is).
i resolved the problem for me with an environmentevent:
start macroeditor (alt+f11)
open macroproject / EnvironmentEvents
paste the follwing code:
Private Sub DocumentEvents_DocumentOpened(ByVal Document As EnvDTE.Document) Handles DocumentEvents.DocumentOpened
If (Not Document Is Nothing) Then
If (Document.FullName.ToLower().EndsWith(".cs")) Then
Try
DTE.ExecuteCommand("Edit.ExpandAllOutlining")
Catch ex As Exception
End Try
End If
End If
End Sub
Private Sub WindowEvents_WindowActivated(ByVal GotFocus As EnvDTE.Window, ByVal LostFocus As EnvDTE.Window) Handles WindowEvents.WindowActivated
If (Not GotFocus Is Nothing) Then
If (Not GotFocus.Document Is Nothing) Then
If (GotFocus.Document.FullName.ToLower().EndsWith(".cs")) Then
Try
DTE.ExecuteCommand("Edit.ExpandAllOutlining")
Catch ex As Exception
End Try
End If
End If
End If
End Sub
Greetings
Tobi

Categories