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. Source code formatting tools

Source code formatting tools

Scheduled Pinned Locked Moved The Lounge
c++comtoolsquestionlearning
17 Posts 13 Posters 0 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.
  • B billb2112

    Can anyone recommend a C++ source code formatting tool? I've inherited a project where the programmer was tab happy, there's whitespace everywhere. Of course, it's just not formatted to my liking either and I'd like to replace the tabs with spaces and remove the extra whitespace that makes the cursor jump all over the place when you arrow through the code. Anyhow, any recommendations are appreciated, the more flexible and complex the better. Thanks, Bill http://www.ratebeer.com

    J Offline
    J Offline
    Jim Wuerch
    wrote on last edited by
    #6

    ack! noooooo! Not someone who gets rid of tabs... hehe. /me runs from the ensuing holy war :) Jim Wuerch www.miwasoft.com Quote from my readme files: "This is BETA software, and as such may completely destroy your computer, change the alignment of the planets and invert the structure of the universe."

    B B C 3 Replies Last reply
    0
    • J Jim Wuerch

      ack! noooooo! Not someone who gets rid of tabs... hehe. /me runs from the ensuing holy war :) Jim Wuerch www.miwasoft.com Quote from my readme files: "This is BETA software, and as such may completely destroy your computer, change the alignment of the planets and invert the structure of the universe."

      B Offline
      B Offline
      Brad Bruce
      wrote on last edited by
      #7

      I agree with keeping tabs. I've worked with several developers who use spaces instead of tabs. Not only that but they use 2 spaces per indentation. It's a nightmare converting to my preference of 4 spaces. If only they would just use the tab and set up their editor to use 2 spaces per tab... Besides, when you add // to the beginning of a line that uses spaces, it really trashes the code! Brad Bruce

      1 Reply Last reply
      0
      • J Jim Wuerch

        ack! noooooo! Not someone who gets rid of tabs... hehe. /me runs from the ensuing holy war :) Jim Wuerch www.miwasoft.com Quote from my readme files: "This is BETA software, and as such may completely destroy your computer, change the alignment of the planets and invert the structure of the universe."

        B Offline
        B Offline
        Bjoern Graf
        wrote on last edited by
        #8

        Recently found the tool Artistic Style [1] to format source code. Even thought it's not perfect it does a far better job than VC. Bjørn. [1] http://astyle.sourceforge.net/

        1 Reply Last reply
        0
        • B billb2112

          Can anyone recommend a C++ source code formatting tool? I've inherited a project where the programmer was tab happy, there's whitespace everywhere. Of course, it's just not formatted to my liking either and I'd like to replace the tabs with spaces and remove the extra whitespace that makes the cursor jump all over the place when you arrow through the code. Anyhow, any recommendations are appreciated, the more flexible and complex the better. Thanks, Bill http://www.ratebeer.com

          J Offline
          J Offline
          Jonathan Gilligan
          wrote on last edited by
          #9

          I haven't used in in quite a while, but GNU indent used to be phenomenally flexible and powerful at this kind of thing. For an example how flexible and complex, the manual tells us that

          The Kernighan & Ritchie style corresponds to the following set of options:

          -nbad -bap -bbo -nbc -br -brs -c33 -cd33 -ncdb -ce -ci4 -cli0
          -cp33 -cs -d0 -di1 -nfc1 -nfca -hnl -i4 -ip0 -l75 -lp -npcs
          -nprs -npsl -saf -sai -saw -nsc -nsob -nss

          while

          Option settings which correspond to the GNU style are:

          -nbad -bap -nbc -bbo -bl -bli2 -bls -ncdb -nce -cp1 -cs -di2
          -ndj -nfc1 -nfca -hnl -i2 -ip5 -lp -pcs -nprs -psl -saf -sai
          -saw -nsc -nsob

          Is that complex enough for you? But seriously, this should do everything you want in terms of reformatting arbitrarily pathologically formatted code into something you can read! Bomb our homes and threaten our children, and, as difficult as it is, we will still love you --- Martin Luther King, Jr.

          B C I 3 Replies Last reply
          0
          • J Jim Wuerch

            ack! noooooo! Not someone who gets rid of tabs... hehe. /me runs from the ensuing holy war :) Jim Wuerch www.miwasoft.com Quote from my readme files: "This is BETA software, and as such may completely destroy your computer, change the alignment of the planets and invert the structure of the universe."

            C Offline
            C Offline
            Chris Maunder
            wrote on last edited by
            #10

            Personally I can't stand tabs in code becuase I often open source files in WordPad and it always has tabbed code out of alignment (I think it's default tab size is 8?). Whitespace doesn't make programs run any slower, but they do make it easier to read the code when opened in any text viewer. Just my contribution to the start of the next religious war ;) cheers, Chris Maunder (CodeProject)

            L 1 Reply Last reply
            0
            • C Chris Maunder

              Personally I can't stand tabs in code becuase I often open source files in WordPad and it always has tabbed code out of alignment (I think it's default tab size is 8?). Whitespace doesn't make programs run any slower, but they do make it easier to read the code when opened in any text viewer. Just my contribution to the start of the next religious war ;) cheers, Chris Maunder (CodeProject)

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #11

              Just looking for something to say to rack up number 700 and what do I see Chris flapping his gums. :-D I gotten hold of this and now I won't let go. What in the hell would you want to use WordPad for? Even if it is just to view source. Don't you find it a major pain in the arse when you add // to the beginning of a line? Screws up the formatting something chronic. Gotta go, have a train to catch, will pick this up hen I get home and login. Anyway shouldn't you be using your spare time to answer questions in your CComboCompletion article and organising that beer with me in the near future? ;P Michael Martin Pegasystems Pty Ltd Australia martm@pegasystems.com +61 413-004-018 "Don't belong. Never join. Think for yourself. Peace" - Victor Stone

              1 Reply Last reply
              0
              • D David Wulff

                In MSDEV: CTRL+A CTRL+F8 (it may be F7) It isn't felxible, but it will make it look prettier in the meant time whilst you find a suitable alternative.

                :cool: -=:suss:=-

                David Wulff dwulff@battleaxesoftware.com

                B Offline
                B Offline
                billb2112
                wrote on last edited by
                #12

                It is Alt-F8, and that isn't going to cut the mustard at the moment. There are all kinds of spacing problems within parenthesis and such that Alt-F8 doesn't touch.

                1 Reply Last reply
                0
                • J Jonathan Gilligan

                  I haven't used in in quite a while, but GNU indent used to be phenomenally flexible and powerful at this kind of thing. For an example how flexible and complex, the manual tells us that

                  The Kernighan & Ritchie style corresponds to the following set of options:

                  -nbad -bap -bbo -nbc -br -brs -c33 -cd33 -ncdb -ce -ci4 -cli0
                  -cp33 -cs -d0 -di1 -nfc1 -nfca -hnl -i4 -ip0 -l75 -lp -npcs
                  -nprs -npsl -saf -sai -saw -nsc -nsob -nss

                  while

                  Option settings which correspond to the GNU style are:

                  -nbad -bap -nbc -bbo -bl -bli2 -bls -ncdb -nce -cp1 -cs -di2
                  -ndj -nfc1 -nfca -hnl -i2 -ip5 -lp -pcs -nprs -psl -saf -sai
                  -saw -nsc -nsob

                  Is that complex enough for you? But seriously, this should do everything you want in terms of reformatting arbitrarily pathologically formatted code into something you can read! Bomb our homes and threaten our children, and, as difficult as it is, we will still love you --- Martin Luther King, Jr.

                  B Offline
                  B Offline
                  billb2112
                  wrote on last edited by
                  #13

                  Ya, now we're getting somewhere. I guess one thing that I forgot to mention that makes things look bad are the tons of tabs/spaces in between function names and return types in the prototype. I can see where you'd want to perhaps line up all of the names, but having void, then the function name is a little ridiculous. There is also erratic tabbing inside of things that conditions. if (blah ) { } I don't get what someone was trying to accomplish in that sort of situation. This is going to be a doozy I think :> Thanks for all of the help and posts so far folks.

                  1 Reply Last reply
                  0
                  • J Jonathan Gilligan

                    I haven't used in in quite a while, but GNU indent used to be phenomenally flexible and powerful at this kind of thing. For an example how flexible and complex, the manual tells us that

                    The Kernighan & Ritchie style corresponds to the following set of options:

                    -nbad -bap -bbo -nbc -br -brs -c33 -cd33 -ncdb -ce -ci4 -cli0
                    -cp33 -cs -d0 -di1 -nfc1 -nfca -hnl -i4 -ip0 -l75 -lp -npcs
                    -nprs -npsl -saf -sai -saw -nsc -nsob -nss

                    while

                    Option settings which correspond to the GNU style are:

                    -nbad -bap -nbc -bbo -bl -bli2 -bls -ncdb -nce -cp1 -cs -di2
                    -ndj -nfc1 -nfca -hnl -i2 -ip5 -lp -pcs -nprs -psl -saf -sai
                    -saw -nsc -nsob

                    Is that complex enough for you? But seriously, this should do everything you want in terms of reformatting arbitrarily pathologically formatted code into something you can read! Bomb our homes and threaten our children, and, as difficult as it is, we will still love you --- Martin Luther King, Jr.

                    C Offline
                    C Offline
                    Chris Losinger
                    wrote on last edited by
                    #14

                    i see a program that needs a GUI front end. -c ------------------------------ Smaller Animals Software, Inc. http://www.smalleranimals.com

                    1 Reply Last reply
                    0
                    • A Alvaro Mendez

                      Hi Bill, Have you tried my DevStudio macro? It works with DevStudio's Smart Indent and Tab settings, but it does a lot more. It also ensures that operators, curly braces, case statements, and other such things are properly formatted and spaced. Your code will end up looking a lot like MFC's source code, which I happen to like. Regards, Alvaro

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #15

                      Bill, I recommend you give this a go. Works perfectly for me, corrects all those formatting screwups Chris puts in his code. ;) Michael Martin Pegasystems Pty Ltd Australia martm@pegasystems.com +61 413-004-018 "Don't belong. Never join. Think for yourself. Peace" - Victor Stone

                      1 Reply Last reply
                      0
                      • J Jonathan Gilligan

                        I haven't used in in quite a while, but GNU indent used to be phenomenally flexible and powerful at this kind of thing. For an example how flexible and complex, the manual tells us that

                        The Kernighan & Ritchie style corresponds to the following set of options:

                        -nbad -bap -bbo -nbc -br -brs -c33 -cd33 -ncdb -ce -ci4 -cli0
                        -cp33 -cs -d0 -di1 -nfc1 -nfca -hnl -i4 -ip0 -l75 -lp -npcs
                        -nprs -npsl -saf -sai -saw -nsc -nsob -nss

                        while

                        Option settings which correspond to the GNU style are:

                        -nbad -bap -nbc -bbo -bl -bli2 -bls -ncdb -nce -cp1 -cs -di2
                        -ndj -nfc1 -nfca -hnl -i2 -ip5 -lp -pcs -nprs -psl -saf -sai
                        -saw -nsc -nsob

                        Is that complex enough for you? But seriously, this should do everything you want in terms of reformatting arbitrarily pathologically formatted code into something you can read! Bomb our homes and threaten our children, and, as difficult as it is, we will still love you --- Martin Luther King, Jr.

                        I Offline
                        I Offline
                        Igor Proskuriakov
                        wrote on last edited by
                        #16

                        The main issue with GNU indent is that it does not understand C++, only plain C. To illustrate this problem I can mention that code after running through indent can stop compiling. Something like vector > can become vector>. Artistic Style does understand C++ but lacks all the options which indent has. The macro on codeproject.com does not have any configuration, but I personally like its setup. Unfortunately there are still some bugs in it. Hope it helps. Igor Proskuriakov

                        1 Reply Last reply
                        0
                        • B billb2112

                          Can anyone recommend a C++ source code formatting tool? I've inherited a project where the programmer was tab happy, there's whitespace everywhere. Of course, it's just not formatted to my liking either and I'd like to replace the tabs with spaces and remove the extra whitespace that makes the cursor jump all over the place when you arrow through the code. Anyhow, any recommendations are appreciated, the more flexible and complex the better. Thanks, Bill http://www.ratebeer.com

                          J Offline
                          J Offline
                          Joel Lucsy
                          wrote on last edited by
                          #17

                          Try http://www.ochre.com.au/ Joel Lucsy (jjlucsy@concentric.net)

                          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