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 $$anonymous$$ · Jan 08, 2014 at 10:59 AM · monodevelopformatting

Indentation formatting issue in MonoDevelop-Unity 4.0.1 (Win7)

Hi all,

I'm having an issue with MonoDevelop that came with Unity 4.3.2f1 on Windows 7 where the conditional and iterative blocks I write get "corrected" with excessive indentation and badly-aligned closing braces, like so:

alt text

I've tried looking into the C# formatting options, but couldn't tweak or find anything that would solve this issue. Google search turned up nothing either. Anyone able to help?

Thanks!

monodevelop_4_bad_formatting.jpg (21.4 kB)
Comment
Add comment · Show 5
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 Jamora · Jan 15, 2014 at 03:35 PM 0
Share

This looks like ins$$anonymous$$d of excessive indenting, you're missing a tab before all your statements.

If you put the opening braces on a new line by pressing enter, do they align with the closing braces?

Having opened a block in the beginning of the code can cause this (a namespace, being in a nested class...). Opening braces ("{") add an intentation level to anything after them in $$anonymous$$onoDevelop, by default.

avatar image $$anonymous$$ · Jan 15, 2014 at 07:49 PM 0
Share

I tried doing that as well (opening brace on new line), but upon applying the closing brace, the thing auto-formats and pulls the opening brace to the same line as the block opener and formats its contents the same way.

avatar image Jamora · Jan 15, 2014 at 08:55 PM 0
Share

if you're inside a namespace or some such block of code, the editor will add a level of indentation. In fact, it will add a level of indentation for any opening brace.

If you're bothered by the added indentation, you need to edit the indentation policy for C# files, as described below, to not indent for whatever block of code causes you trouble.

avatar image Skaffel · Jan 17, 2014 at 04:46 PM 0
Share

Have the same problem. Same version and I do also use windows 7, but it only happens to one of my computers. The settings are the same, quite annoying. Hope I will find a fix soon.

avatar image Berzeger · Mar 14, 2014 at 06:46 PM 0
Share

I have the same problem... It is very annoying and I hope it'll get fixed ASAP.

3 Replies

· Add your reply
  • Sort: 
avatar image
7
Best Answer

Answer by Berzeger · Mar 14, 2014 at 07:16 PM

This was driving me nuts! But I found a fix -- in MonoDevelop go to Tools -> Options -> Text Editor -> Behavior and switch Indentation Mode from Smart to Automatic. Not so smart after all, huh? Kudos to BoNaNa from Unity forums who solved it.

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 RowedRage0 · Jan 14, 2014 at 07:00 PM

First let me say I had a lot of trouble with this. I find the Policy setup very confusing in MonoDevelop. I had a similar issue but found in the end that I was formatting my document based on the wrong policy. I'll try to explain why it wasn't working, but that might not be the issue here.

Essentially, there are Personal Preference formatting options, Solution formatting options, and Project formatting options. Project options can inherit from the Solution options. I think it uses Personal formatting options as defaults when you create a project, but I'm not sure. When I had issues with formatting, it was because I had Project specific formatting stomping on the Solution's options.

To set Solution formatting, go to Project -> Solution Options -> Source Code / Formatting. There you can set the format for each filetype to a standard policy or one that you've imported. To set Project formatting, make sure you have your project loaded and then go to Project -> Options -> Source code / Formatting. Same deal with setting the policies here, it's just that it applies to the Solution. You can also set the policy to Inherited to get the settings from the Solution.

After you've adjusted the options, Formatting the document should apply those to the code.

Hope that's helpful, even if it's not the answer you were looking for.

Note: I think Project -> "Apply Policy" adjusts the options for the Project only. I'm probably not going to touch that feature in the future.

Comment
Add comment · Show 2 · 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 $$anonymous$$ · Jan 15, 2014 at 06:55 AM 0
Share

The policy I have seems to look good, but trying to apply it just causes the same indentation issues. This basically happened upon installation, so no configuration was done before I saw this problem :(

avatar image RowedRage0 · Jan 15, 2014 at 03:22 PM 0
Share

Hmm sorry it wasn't helpful. The weird bracket indentation seems strange, and suggests it's not a formatting thing at all, since no scheme I've seen would do it like that.

If you go to view the formatting options for your code does it show up in the preview window the same way it shows up here? And also, I assumed the code shown is the result after formatting but is that true? If you "fix" it and then format it does it go back to what is shown here?

avatar image
0

Answer by Transigence · Oct 20, 2014 at 11:39 AM

MonoDevelop 4.0.12 on Ubuntu 14.04 I found this issue as well and put a video of it up here: http://youtu.be/kyjBUsQU3rs

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

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

23 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

Related Questions

Stop Monodvelop adding new line when using attribute 1 Answer

Set Default MonoDevelop Formatting Options 3 Answers

Unity3d/Monodevelop formatting and tab settings 1 Answer

MonoDevelop formatting doesn't seem to work properly,MonoDevelop formatting doesn't seem to work properly 0 Answers

MonoDevelop not respecting formatting settings 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