Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Why Cuddled Braces Suck Today

Why Cuddled Braces Suck Today

Scheduled Pinned Locked Moved The Lounge
csharpvisual-studiotoolsquestion
14 Posts 5 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DaveX86
    wrote on last edited by
    #1

    ...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?

    G 1 Reply Last reply
    0
    • D DaveX86

      ...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?

      G Offline
      G Offline
      Gary Wheeler
      wrote on last edited by
      #2

      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;

      D 1 Reply Last reply
      0
      • G Gary Wheeler

        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;

        D Offline
        D Offline
        DaveX86
        wrote on last edited by
        #3

        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...

        G D 2 Replies Last reply
        0
        • D DaveX86

          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...

          G Offline
          G Offline
          Gary Wheeler
          wrote on last edited by
          #4

          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;

          D 1 Reply Last reply
          0
          • D DaveX86

            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...

            D Offline
            D Offline
            Dario Solera
            wrote on last edited by
            #5

            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

            D 1 Reply Last reply
            0
            • G Gary Wheeler

              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;

              D Offline
              D Offline
              DaveX86
              wrote on last edited by
              #6

              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.

              G 1 Reply Last reply
              0
              • D Dario Solera

                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

                D Offline
                D Offline
                DaveX86
                wrote on last edited by
                #7

                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 :(

                L 1 Reply Last reply
                0
                • D DaveX86

                  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.

                  G Offline
                  G Offline
                  Gary Wheeler
                  wrote on last edited by
                  #8

                  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;

                  D 1 Reply Last reply
                  0
                  • D DaveX86

                    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 :(

                    L Offline
                    L Offline
                    leppie
                    wrote on last edited by
                    #9

                    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

                    D 1 Reply Last reply
                    0
                    • G Gary Wheeler

                      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;

                      D Offline
                      D Offline
                      DaveX86
                      wrote on last edited by
                      #10

                      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.

                      G P 2 Replies Last reply
                      0
                      • L leppie

                        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

                        D Offline
                        D Offline
                        DaveX86
                        wrote on last edited by
                        #11

                        See reply to Gary above :)

                        1 Reply Last reply
                        0
                        • D DaveX86

                          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.

                          G Offline
                          G Offline
                          Gary Wheeler
                          wrote on last edited by
                          #12

                          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;

                          D 1 Reply Last reply
                          0
                          • G Gary Wheeler

                            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;

                            D Offline
                            D Offline
                            DaveX86
                            wrote on last edited by
                            #13

                            I'll give it a whirl when I have a 'mo...cheers :)

                            1 Reply Last reply
                            0
                            • D DaveX86

                              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.

                              P Offline
                              P Offline
                              Peter Mulholland
                              wrote on last edited by
                              #14

                              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

                              1 Reply Last reply
                              0
                              Reply
                              • Reply as topic
                              Log in to reply
                              • Oldest to Newest
                              • Newest to Oldest
                              • Most Votes


                              • Login

                              • Don't have an account? Register

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • World
                              • Users
                              • Groups