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.
- Qt IDE still has no option to "remove empty lines " from editor.
- There MAY BE "plug-ins" beautifiers with such option. The key word is
MAYBE. - 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".
-
Moved to tools since it's a question wrt QtCreator.
-
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 ) -
@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. -
@AnneRanch
Hi
well its both a plugin and a download.
1:
Goto About->pluginsthen we get the (Install plugin window)
I then search for "be" to get the beautifier plugin.
I enable that and restart producer2:
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 -> OptionsNow 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 filein Tools->options
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.
-
J JonB referenced this topic on