Why Cuddled Braces Suck Today
-
...well, because they make code unreadable, that's why :) The habit came from the era of punch cards and dot matrix printers and trying to save extra lines. Do people even make printouts anymore? Does anybody know of a handy method, utility, search/replace technique that can be run inside Visual Studio to un-cuddle all the braces and put things on their own line in a civilized manner?
-
...well, because they make code unreadable, that's why :) The habit came from the era of punch cards and dot matrix printers and trying to save extra lines. Do people even make printouts anymore? Does anybody know of a handy method, utility, search/replace technique that can be run inside Visual Studio to un-cuddle all the braces and put things on their own line in a civilized manner?
YMMV, but In Visual Studio 2008, select Edit, Advanced, Format document. Note: I don't use this feature myself, as it botches up my already immaculate formatting :rolleyes:.
Software Zen:
delete this;
-
YMMV, but In Visual Studio 2008, select Edit, Advanced, Format document. Note: I don't use this feature myself, as it botches up my already immaculate formatting :rolleyes:.
Software Zen:
delete this;
VS 2010 also has it...just tried it...didn't work though :) Maybe there's a 'style' setting somewhere that you can customize and it'll apply it? The IDE that comes with Flash CS3 sucks but it had that one feature that it'd un-cuddle or cuddle as you preferred...I'm surprised there's nothing like that in Visual Studio...
-
VS 2010 also has it...just tried it...didn't work though :) Maybe there's a 'style' setting somewhere that you can customize and it'll apply it? The IDE that comes with Flash CS3 sucks but it had that one feature that it'd un-cuddle or cuddle as you preferred...I'm surprised there's nothing like that in Visual Studio...
You may need to select the text you wish to reformat. Also, I believe the rules it uses to reformat the text are controlled by the options under Tools, Options, Text Editor, {language}, Formatting.
Software Zen:
delete this;
-
VS 2010 also has it...just tried it...didn't work though :) Maybe there's a 'style' setting somewhere that you can customize and it'll apply it? The IDE that comes with Flash CS3 sucks but it had that one feature that it'd un-cuddle or cuddle as you preferred...I'm surprised there's nothing like that in Visual Studio...
DaveX86 wrote:
Maybe there's a 'style' setting somewhere that you can customize and it'll apply it?
Yes, you can define your styling in Tools | Options -> Text Editor -> C# (or any other language).
If you truly believe you need to pick a mobile phone that "says something" about your personality, don't bother. You don't have a personality. A mental illness, maybe, but not a personality. [Charlie Brooker] ScrewTurn Wiki, Continuous Localization and My Startup
-
You may need to select the text you wish to reformat. Also, I believe the rules it uses to reformat the text are controlled by the options under Tools, Options, Text Editor, {language}, Formatting.
Software Zen:
delete this;
There is a 'Format Selection' as well as 'Format Document' in VS 2010. I checked the formatting options for C# and it has some settings that look hopeful but the language I'm using is PHP via a 3rd party addon called VS.PHP from JCX Software...no such formatting options for that. PHP is another C derivative though and most of the same rules apply.
-
DaveX86 wrote:
Maybe there's a 'style' setting somewhere that you can customize and it'll apply it?
Yes, you can define your styling in Tools | Options -> Text Editor -> C# (or any other language).
If you truly believe you need to pick a mobile phone that "says something" about your personality, don't bother. You don't have a personality. A mental illness, maybe, but not a personality. [Charlie Brooker] ScrewTurn Wiki, Continuous Localization and My Startup
Yeah, C# has all kinds of them: Place open brace on new line for types Place open brace on new line for methods Place open brace on new line for anonymous methods Place open brace on new line for control blocks Place open brace on new line for anonymous types ... ... ...unfortunately my PHP addon doesn't have all those :(
-
There is a 'Format Selection' as well as 'Format Document' in VS 2010. I checked the formatting options for C# and it has some settings that look hopeful but the language I'm using is PHP via a 3rd party addon called VS.PHP from JCX Software...no such formatting options for that. PHP is another C derivative though and most of the same rules apply.
It could be some of this is controlled by the extension on the source filename. Editing "*.php" (or whatever the extension is) may reduce it to plain text, which has no reformatting support. Try changing the extension to the language closest to what you're interested in.
Software Zen:
delete this;
-
Yeah, C# has all kinds of them: Place open brace on new line for types Place open brace on new line for methods Place open brace on new line for anonymous methods Place open brace on new line for control blocks Place open brace on new line for anonymous types ... ... ...unfortunately my PHP addon doesn't have all those :(
DaveX86 wrote:
...unfortunately my PHP addon doesn't have all those :(
Change the extension to .cs ;P
xacc.ide
IronScheme - 1.0 RC 1 - out now!
((λ (x) `(,x ',x)) '(λ (x) `(,x ',x))) The Scheme Programming Language – Fourth Edition -
It could be some of this is controlled by the extension on the source filename. Editing "*.php" (or whatever the extension is) may reduce it to plain text, which has no reformatting support. Try changing the extension to the language closest to what you're interested in.
Software Zen:
delete this;
That'd be cool except the PHP files are executed by IIS and need the *.PHP extension to be executed by the PHP interpreter. I'm writing/debugging a Joomla CMS addon and there's many hundreds of PHP files in Joomla...renaming them all to *.CS, do a format, then rename back to *.PHP would be [insert language construct here :] On a side note, working with PHP is a lot more pleasant if you can do it from inside your familiar Visual Studio environment :) Update: ...not to mention that PHP mixes code in *.PHP files but also *.HTML files and *.TPL files, etc.
-
DaveX86 wrote:
...unfortunately my PHP addon doesn't have all those :(
Change the extension to .cs ;P
xacc.ide
IronScheme - 1.0 RC 1 - out now!
((λ (x) `(,x ',x)) '(λ (x) `(,x ',x))) The Scheme Programming Language – Fourth Edition -
That'd be cool except the PHP files are executed by IIS and need the *.PHP extension to be executed by the PHP interpreter. I'm writing/debugging a Joomla CMS addon and there's many hundreds of PHP files in Joomla...renaming them all to *.CS, do a format, then rename back to *.PHP would be [insert language construct here :] On a side note, working with PHP is a lot more pleasant if you can do it from inside your familiar Visual Studio environment :) Update: ...not to mention that PHP mixes code in *.PHP files but also *.HTML files and *.TPL files, etc.
Just rename them temporarily to use the VS reformatter. I'd be willing to bet there's more than one PHP source reformatter (or 'pretty printer') out there.
Software Zen:
delete this;
-
Just rename them temporarily to use the VS reformatter. I'd be willing to bet there's more than one PHP source reformatter (or 'pretty printer') out there.
Software Zen:
delete this;
-
That'd be cool except the PHP files are executed by IIS and need the *.PHP extension to be executed by the PHP interpreter. I'm writing/debugging a Joomla CMS addon and there's many hundreds of PHP files in Joomla...renaming them all to *.CS, do a format, then rename back to *.PHP would be [insert language construct here :] On a side note, working with PHP is a lot more pleasant if you can do it from inside your familiar Visual Studio environment :) Update: ...not to mention that PHP mixes code in *.PHP files but also *.HTML files and *.TPL files, etc.
Just looked at VS2008 and under Text Editor in the tools dialog, there's a File Extensions item. You could try adding .PHP to the extensions for C# or C++, maybe?
Pete