- Home /
MonoDevelop - disable automatic whitespace between function name and round brackets?
Is there a setting to have MonoDevelop not insert an automatic whitespace between a function call and the round brackets? It automatically formats to this:
private void Foo () {}
Foo ();
But I want this:
private void Foo() {}
Foo();
$$anonymous$$ine doesn't do that, and I don't remember ever changing a setting in it.
It happens when typing through a Intellisense suggestion. For example, typing
Debug.Log(
results in
Debug.Log (
Now why would you want your code to look uglier? It does it for a reason, you know.
Clearly this isn't a life or death issue, and I haven't lost any sleep over the extra space yet. But "uglier" is debatable - in fact I know many codebases (and company coding standards) that omit the space between the brackets. Would be nice to have this IDE do the same.
I also prefer no space between the method name and the brackets, that's why i use Visual Studio ;)
Answer by Lo0NuhtiK · May 06, 2012 at 03:55 PM
In mono go to
[Project]->[Assembly C# Options] -> [Source Code] -> [Code Formatting] ->
[C# Source Code] -> Change [Policy] to Mono , then Click the "C# Format" tab, and mess with the settings in there. That's where you can set the indentations etc for all that stuff.
I just now went in there a couple of minutes ago and found that. Mine was set to "Inherited Policy" and none of the parenthesis brackets spacing like you mention above happened on mine at all.
I'm glad you asked this question... now I have it set to auto-indent my switch statements the way I want it to :D
Likewise I've been wanting these settings for ages! Fantastic! Thanks!
Cool, there were a whole bunch of options in there that I hadn't noticed before, hidden in the Category dropdown. FYI, I used the main $$anonymous$$onoDevelop preferences (rather than project-specific ones) in $$anonymous$$onoDevelop-Unity->Preferences->Source Code->Code Formatting->C#. The option I was looking for is first up in the White Space section.
I created a $$anonymous$$onoDevelop policy to encapsulate all these settings and share with the rest of my dev $$anonymous$$m. Works great, except we need to re-apply the policy each time we generate the solution -- anyone know how to change the default policy used by $$anonymous$$onoDevelop?
I've created a policy like this, but I have to re-apply it to my solution/assembly everytime I re-open $$anonymous$$onoDevelop. Has anybody found a way to make the changes permanent?
Answer by badweasel · Jan 19, 2015 at 08:51 PM
Just to clarify something.
If you've already started a project, which you would have or you wouldn't be in MonoDevelop cursing at all the white space, then the Per Project settings will override the main Preferences.
So you basically have to change it in both places. I started with Preferences->Source Code and was super frustrated that it didn't seem to effect my open files. Then looking here I found out that there is also the same setting under Project->Assembly C# Options.
Probably on the next project it would just inherit from the preferences. But to get it to be correct on this project I had to change it in both places.
Answer by jhocking · Mar 15, 2013 at 05:38 PM
The answer loonuhtik gave is correct for per-project settings, but to do it in a global way that will apply to new projects there's the exact same settings dialog under Preferences->Source Code.
Answer by Xentor609 · Nov 02, 2015 at 10:07 PM
The problem comes from Unity. In fact it re-generates the solution with the default policy.
I use a workaround that overwrites the contents of the solution. I based on the following link : https://gist.github.com/prime31/35a83fb8ad4eb385ab22
I just found another one that supports mac : https://gist.github.com/Capyvara/9090942
Good luck, Xentor
Your answer
Follow this Question
Related Questions
monodevelop formatting policy to allow single-line 'if' statemetns? 2 Answers
Precompiler directives break MonoDevelop autoformat 0 Answers
MonoDevelop 4.0.1 auto (de)formatting 0 Answers
Stop Monodvelop adding new line when using attribute 1 Answer
Indentation formatting issue in MonoDevelop-Unity 4.0.1 (Win7) 3 Answers