- Home /
How to stop MonoDevelop auto-collapsing curly brackets?
Hey all.
I'm brand spanking new to Unity and Monodevelop AND coding in general.
I'm learning some basic C# now and I'm trying to keep all my code well spaced with lots of comment lines so I can make sense of what I'm typing.
However when I add an end curly bracket to something, for example an else statement, it will automatically collapse all the spaces in the if statement and put curly brackets at the end of the if statement line, instead of in the next line (which is a bit cleaner for me to look at).
Is there a way to turn off this auto re formatting? And if so, could you please explain it specifically?
I've looked through the prefs and solution options and I'm sure it's in there, but I don't know what to switch on or off.
Many thanks!
$$anonymous$$aybe One of the check boxes under Tools -> Options -> Text Editor -> Behavior?
Something doesn't sound right with what you're saying. Can you post the code when it's done the weird formatting? It could be that you have an error and it's unable to figure out how to format correctly because of it (Happens a lot actually).
Answer by ryandb2 · Jan 20, 2014 at 06:52 AM
I know this is an older topic, but for anyone who needs it, go to Options -> Source Code -> Code Formatting -> C# Source Code, open that, click the tab for C# Format, then click edit. In the category Indentation, look under "Statements" and uncheck "within blocks".
Great - I didn't even know all those options existed. Was able to turn off many auto-formatting behaviors that I found annoying.
Of course, doing so now un-indents everything within blocks automagically. There's no winning with $$anonymous$$onoDevelop...
matt_b have a better solution. http://answers.unity3d.com/questions/580059/how-to-stop-monodevelop-auto-collapsing-curly-brac.html#answer-1188076
Answer by matt_b_ · May 17, 2016 at 01:46 PM
To fix this go to Tools > Options > Source Code > Code Formatting > C# Source Code
Click the C# Format tab then click Edit. Then you select the New Lines category & change "Place 'else' on new line" to Always new line.
Answer by AmiN47 · Jul 08, 2016 at 07:35 PM
go to "Tools > Options > Source Code > Code Formatting > C# Source Code > C# Format > Edit (button)".
then select braces and change everything you want to "End of the line". hope it solves your problem ;)
Answer by tess_wtmk · Nov 22, 2013 at 12:23 AM
Hi Ross - I checked under tools but there wasn't an Option menu. There are text behaviour modifiers in the Prefs and Solution options but I'm kinda looking for a specific one to help stop this.
I should mention I'm using the latest version of Unity (4.3) and whatever Monodevelop comes with that, and running it on a Mac.
Hi ThePunisher. Here are some screenshots to help illustrate:
How I type it out / want it to look:
And then as soon as I add that last curly bracket:
It's not changing the code or creating errors or anything, but it is annoying especially as I'm learning and want to see everything laid out clearly. The main thing is the curly brackets moving to the end and beginning of lines, that makes it very confusing for me.
That's weird. $$anonymous$$aybe the macs mono-develop's menus are different. The option I was thinking might be causing the problem is called "Enable on the fly code formatting" Under Automatic Behaviors. But its grayed out on my system for whatever reason so i can't really test it.
Answer by h4le5torm · Feb 03, 2017 at 07:12 PM
AmiN's solution worked for me: go to "Tools > Options > Source Code > Code Formatting > C# Source Code > C# Format > Edit (button)". Then select braces and change everything you want to "End of the line".
Your answer
Follow this Question
Related Questions
Why can't I edit C# script although I have monodevelop installed? PLEASE HELP 1 Answer
Automatic caching in Mono? 0 Answers
Monodevelop autocomplete help! 2 Answers
mono devolpe 1 Answer