VisualStudio curly brackets won't indent macos - c#

I downloaded and installed visual studio on my mac to work with xamarin and every time I try to use the text editor I just can't.
This is how the layout looks like:
Visual studio text editor
And this is how it looks like when I use monoDevelop instead:
MonoDevelop text editor
Now, I want to use xamarin and I can't seem to find a solution to the brackets acting they way they do. If anyone can help I would much appriciate it. It's been bothering me for a while now.

It seems like the tabs for C# were not set up correctly within your Visual Studio.
Please try the following:
a) On the 'Tools' menu, click 'Options'.
b) Click 'Text Editor'.
c) Open C# and click 'Tabs'.
d) Make sure that 'Smart' Indentation is selected.
For further information please check out: https://msdn.microsoft.com/en-us/library/999b219z(v=vs.71).aspx
Note
You can automatically let Visual Studio indent your code:
Autoformat selection: Ctrl+K, Ctrl+F
Autoformat document: Ctrl+K, Ctrl+D

Related

Visual Studio 2022 turn off auto indenting

So i upgraded to VS 2022. and anytime i add a semicolon. the whole code block gets backtabbed. does anyone know how to turn this off? getting tired of hitting ctrl z repeatedly..
Before.
After
Go to VS2022 Tools - Options Menu
Type indent in search
Look for Indentation under formatting option which appears under
Text Editor - C# - Code Style - Formatting Indentation
check / uncheck boxes to see how your code will look and save when happy
After consolidating code blocks to one block on the razor page... this seems to have corrected the issue. the indenting I believe may have been caused by some bug where the indenting fails due to attempting to address other formatted code. this is not really a solid answer but i did find that moving things around prevented this from occuring and this was nothing to do with any indenting settings within the tools text editor options.
I'm not sure if you ever found the correct answer to your question, but I was having the same problem, and reading the other two answers led me to figuring it out. The problem is with the adaptive formatting option being turned on. To turn it off, go to
Tools -> Options -> Text Editor -> Advanced
You should see
Uncheck 'Use adaptive formatting'
Save, and restart Visual Studio
This should do the trick for you.
In visual studio 2022 community:
Go to Tools -> Options -> "Generate .editorconfig file from settings"
Open .editorconfig in some text editor
Search for "indent_size" and "indent_style" and adapt them to your needs
effects are reflected without even restarting visual studio
There is another option under Tools - Options
Text Editor - All Languages - Tabs.
Try to specify Tab size and indent size

Whats the equivalent of TAB +TAB in Visual Studio Code VSCode

In Visual Studio you can use Tab + Tab to automatically create a foreach (or other) structure.
Does VSCode have something similar?
Yes, VSCode does support snippets. They appear in the completion list, and you can insert them by pressing Tab or just Enter. Alternatively, you can use the Insert Snippet command found in the command palette.
The snippet shown in the .gif above is provided by the C# extension.

"Always-indent" style for visual studio express

Is there a way to have Visual Studio (2012 Express) auto-indent like it is possible in XCode or Emacs? Saying auto-indent I mean that the IDE indents to the correct level when pressing TAB no matter what position in the line the cursor is in.
I know I can press Ctrl+K, Ctrl+F or Ctrl+K,D to indent a document or selection, but this is kind of cumbersome. Writing code and just pressing TAB to auto-indent the current line is just much faster. Is there a way to do this in VS?
Go to
Tools -> Options
choose then
Text Editor -> All Languages -> Tabs
There you can specifiy:
Tab size
Indent size
Insert spaces (instead of a tab)

Indenting changed after I re-installed Visual Studio 2010

When I edit C# file in Visual Studio 2010, it looks ok, but when I open it in another IDE or push to github, I notice that indenting is wrong. It happened after I reinstalled Visual Studio.
Any idea how put this on the line again? I do not remember changing any indenting options in previous installation, and I definitely didn't do anything to it this time either.
UPDATE:
By wrong I mean this (faked, since it cannot if copy/pasted it gets ok):
_req = (HttpWebRequest)WebRequestCreator.ClientHttp.Create(new Uri(_options["url"]));
_req.Method = _options["method"];
// disable buffering (this only works for ClientHttp version)
//_req.AllowWriteStreamBuffering = false; // causes silent crash on Mac OS X 10.8.x
in Visual Studio it looks ok. Basically any new line that I add (that didn't exist in files created in previous installation), I get weird indenting.
Probably in your previous installation of VS you have a different settings for your tabs.
Now, the reinstall resetted everything to the default settings.
Check the menu Tools, ->Options, ->Text Editor, ->C#, Tabs
and try with different settings
You can change the automatic formatting of text in Visual Studio by going to Tools --> Options --> Text Editor --> C#.
There you can change the way indentation is done in the Tabs submenu and in --> Formatting --> Indentation.

What is the shortcut to auto import library in visual studio 2010, 2012 (if any- like Alt+Enter in Netbeans)?

I don't know where is the short-cut button to auto generate namespace import in C# winform/ window store... application, like the Alt+Enter shortcut in NetBean IDE. I and some of my friends have programmed in visual studio for several years but when we need to import library, we have to move the cursor after the Class code and click to show namespace like this:
Thank you for your help :)
Try CTRL+. to open up the quick fix which will give you different options to fix such an error, including adding usings for the correct namespace—if VS finds a valid type in the references.
Ctrl+R and Ctrl+G ... OR Ctrl + R + G
Another little option through the toolbar.

Categories

Resources