Or improve your google-fu by finding some existing tools that do the job right. :)
I'm pretty sure Uncrustify is good at most of these issues, not to mention it's a very nice source-code "prettifier/indenter". There's a front-end called UniversalIndentGUI, which has about a dozen integrated versions of source-code prettifiers (including uncrustify, and for many languages). It has varios settings on the left, and togglable *Live* preview mode which you can view on the right.
I invite you guys to try it out sometime:
http://universalindent.sourceforge.net/
(+ you can save different settings which is neat when you're coding for different projects that have different "code design & look" standards)
On 08/06/2010 08:34 PM, Walter Bright wrote:[snip]
I wrote these two trivial utilities for the purpose of canonicalizing
source code before checkins and to deal with FreeBSD's inability to deal
with CRLF line endings, and because I can never figure out the right
settings for git to make it do the canonicalization.
tolf - converts LF, CR, and CRLF line endings to LF.
detab - converts all tabs to the correct number of spaces. Assumes tabs
are 8 column tabs. Removes trailing whitespace from lines.
Posted here just in case someone wonders what they are.
Nice, though they don't account for multiline string literals.
A good exercise would be rewriting these tools in idiomatic D2 and assess the differences.
Andrei