Hi Folks,
So I did it.
With the Edit -> Format -> Format Document / Format Selection menu buttons you will be able to format your code or even the currently selected lines from now on. Don’t expect to much for now, there are just too many parts of D code than can ‘be there’. You will be able to change several formatting options later on either.
As a first result, it’s possible to format code like this:
into something like this:

I’ll push a release when I think that the most important formatting features are in there.
Question to all of you: Which formatting situations are very critical to you *besides* the all-mighty curly bracket formatting? So which things regarding formatting are most important? I guess the correct indentation of all lines, huh?
2 Comments
1) ability to set formatting preferences through a text file. See how Sublime Text does it for a perfect example (they use a json-like file):
{
// Set to false to prevent line numbers being drawn in the gutter
“line_numbers”: true,
…
}
That’ll make it easier to pass around to other ppl, simplifies explanations (no more click on this, click on that), easier interface etc. Actually if all of monoD’s features could be set that way, it’ll be even better. It does syntax check before user saves to avoid wrong settings.
2) expose functionality as a standalone or library :
dformat –input=a.d –output=a2.d –pref=defaults.json
3) implement the usual suspects (spacing after function args, no trailing spaces, hard wrapping on word boundaries after a specified number of columns, no more than 2 blank lines in a row, etc). Companies often require those.
Unrelated:
It would be nice to reopen last opened files upon MD startup.
Well..the feature _is_ new, and I know that there should be a possibility to take control over the single formatting settings – the basic template for the option panel is there already. 1) Will not be done via JSON but in an xml file hidden in the shared MD option files or so
2) Making a stand-alone (okay, still one dll *cough*
) program wouldn’t be that hard. It still won’t be a native program that only fits to one platform after being compiled. — I don’t want to leave the .net/mono track, sry about that
3) That is part of the actual formatting engine I’m currently working on. You ‘can’ already activate it in the D option panel..just have a look into the settings
– I can guarantee you that it’ll crash for longer codes because it still can’t handle all code situations.
The last proposal is a more MD-related thing. I have no control over opening files directly after startup