Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Remove empty lines in editor - code beautifier - REPOST

    Tools
    3
    6
    400
    Loading More Posts
    • 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.
    • A
      AnneRanch last edited by

      I am reposing SAME request instead of tagging it on the old thread.

      My intend is still same - find a WORKING solution to remove empty lines in editor - (C/C++) code beautifier.

      Since I have used "artistic" style I would prefer that as a solution.

      Here is a summary of what transpired since my initial request.

      1. Qt IDE still has no option to "remove empty lines " from editor.
      2. There MAY BE "plug-ins" beautifiers with such option. The key word is
        MAYBE.
      3. There is a link to "astyle", but few months ago somebody posted a note it is no longer actively maintained . ? Not a good incentive to download etc...

      http://astyle.sourceforge.net/

      So the bottom line - again - can anybody point me to an integrated solution with Qt?
      It does not matter what it is called - plug-in etc. - but it has to have an option to remove empty lines from editor.

      Yes, I prefer precompiled Linux version, I am not that good in "configuring".

      1 Reply Last reply Reply Quote 0
      • Christian Ehrlicher
        Christian Ehrlicher Lifetime Qt Champion last edited by

        Moved to tools since it's a question wrt QtCreator.

        Qt has to stay free or it will die.

        1 Reply Last reply Reply Quote 0
        • mrjj
          mrjj Lifetime Qt Champion last edited by

          Hi
          Astyle is a fine formatter. used it for a decade.
          Yes its not been updated much but still does a better job than clang-format and all the new ones.

          You can use it with
          --delete-empty-lines
          (and other formatting options you want )

          alt text

          A 1 Reply Last reply Reply Quote 1
          • A
            AnneRanch @mrjj last edited by

            @mrjj Thanks for your post.
            Can you instruct me how to ADD it to QtCreator?

            I got as far as "add plug-in" and obviously going it wrong .
            It sure looks Qt is adding Astyle for its own plug-in data not from the file downloaded.

            03b20562-5fe5-43d9-91c2-adc73bac404a-image.png

            mrjj 1 Reply Last reply Reply Quote 0
            • mrjj
              mrjj Lifetime Qt Champion @AnneRanch last edited by

              @AnneRanch
              Hi
              well its both a plugin and a download.
              1:
              Goto About->plugins

              then we get the (Install plugin window)

              alt text

              I then search for "be" to get the beautifier plugin.
              I enable that and restart producer

              2:
              then i goto
              https://sourceforge.net/projects/astyle/files/
              and download the code (if linux) and build the exe. (easy)
              OR
              sudo apt-get install astyle
              (its often in the repro)

              3:
              The in Creator
              I go to tools -> Options

              alt text

              Now you need to tell it where to find the "exe".

              Also we need to add Formatting settings.
              So we press Add to make a new "config" and use this.

              I use

              --indent-switches
              --indent-col1-comments
              --pad-oper
              --align-pointer=type
              --indent=spaces=2
              --max-instatement-indent=80
              --style=attach
              --pad-comma
              --add-braces
              --delete-empty-lines
              

              but you should ofc change it to fit your style.
              Many dont like --add-braces
              as it will add {} to a single line if which some find annoying and so on.

              Press ok. and it should work now.

              4: This is optional :)
              Assign a key to format the current file

              in Tools->options
              alt text

              I hope this make sense and you get it running :)

              A 1 Reply Last reply Reply Quote 3
              • A
                AnneRanch @mrjj last edited by AnneRanch

                @mrjj Thanks appreciate all - especially the add to format current file.
                Doing it Qt way gets tiresome...

                75e35bfc-8019-48b7-b624-a85b4b19902c-image.png

                Just because I tried to add some text to "documentation" but it won't take anything.

                It gets little hard to reply and implement it , so I'll get back to you when I get it all put together.

                As another matter -
                since you mentioned brackets
                I like to cut and paste - there is a trick to put mouse behind starting bracket and "select until next bracket " .

                I have been looking for similar to actually select between #iifdef .. #endif . I know the Qt editor puts different background color to show the #ifdef... #endif but I like to copy such range.

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post