Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by tess_wtmk · Nov 21, 2013 at 07:36 AM · monodevelop

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!

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Ross_B · Nov 21, 2013 at 08:21 AM 0
Share

$$anonymous$$aybe One of the check boxes under Tools -> Options -> Text Editor -> Behavior?

avatar image ThePunisher · Nov 21, 2013 at 11:02 PM 0
Share

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).

6 Replies

· Add your reply
  • Sort: 
avatar image
10

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".

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image JoeProgram · Feb 26, 2015 at 11:25 PM 0
Share

Great - I didn't even know all those options existed. Was able to turn off many auto-formatting behaviors that I found annoying.

avatar image PatrickHedges · Dec 28, 2015 at 05:45 PM 0
Share

Of course, doing so now un-indents everything within blocks automagically. There's no winning with $$anonymous$$onoDevelop...

avatar image TRBRY · Aug 11, 2016 at 05:21 PM 0
Share

matt_b have a better solution. http://answers.unity3d.com/questions/580059/how-to-stop-monodevelop-auto-collapsing-curly-brac.html#answer-1188076

avatar image
6

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
5

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 ;)

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

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:

alt text

And then as soon as I add that last curly bracket:

alt text

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.


screen shot 2013-11-22 at 12.13.13 pm.png (65.6 kB)
screen shot 2013-11-22 at 12.15.30 pm.png (62.8 kB)
Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Ross_B · Nov 22, 2013 at 08:18 AM 0
Share

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.

avatar image
0

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".

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
  • 1
  • 2
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

28 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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

MonoDevelop will not autosync with Unity 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges