Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Remove empty lines in editor - code beautifier - REPOST
QtWS25 Last Chance

Remove empty lines in editor - code beautifier - REPOST

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
6 Posts 3 Posters 1.0k Views
  • 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 Offline
    A Offline
    Anonymous_Banned275
    wrote on last edited by
    #1

    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
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

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

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      0
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        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
        1
        • mrjjM mrjj

          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 Offline
          A Offline
          Anonymous_Banned275
          wrote on last edited by
          #4

          @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

          mrjjM 1 Reply Last reply
          0
          • A Anonymous_Banned275

            @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

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @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
            3
            • mrjjM mrjj

              @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 Offline
              A Offline
              Anonymous_Banned275
              wrote on last edited by Anonymous_Banned275
              #6

              @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
              0
              • JonBJ JonB referenced this topic on

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved