Qt World Summit: Submit your Presentation

Remove empty lines in editor - code beautifier - REPOST

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


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

  • Lifetime Qt Champion

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

  • Lifetime Qt Champion

    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
    (and other formatting options you want )

    alt text

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


  • Lifetime Qt Champion

    well its both a plugin and a download.
    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

    then i goto
    and download the code (if linux) and build the exe. (easy)
    sudo apt-get install astyle
    (its often in the repro)

    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


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

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


    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.

Log in to reply