Questions tagged [astyle]

Artistic Style is a source code indenter, formatter, and beautifier for the C, C++, C# and Java programming languages. It can be used from a command line, or it can be incorporated as classes in another C++ program.

Artistic Style is a source code indenter, formatter, and beautifier for the C, C++, C# and Java programming languages.

There are command line options for defining bracket settings, indentation, white-space padding, and line endings. This can be applied to a single file, a set of files, or whole directory folders recursively. Additionally one can choose to create a backup file for each file touched.

For more information, see the project's official site

58 questions
2
votes
2 answers

How to avoid extra 'extern' indent

I used astyle to format my C/C++ source codes, after many tries, it almost satisfied my need except that it added extra indent after the clause extern "c" {. I find that astyle has this feature here, it says "The C/C++ keyword 'extern' no longer…
whatacold
  • 660
  • 7
  • 15
2
votes
1 answer

astyle: is there an option to add a space between `#include` and `<...>`?

For example, this code snippet: #include would becomes: #include I read the document and googled but didn't find one.
user26742873
  • 919
  • 6
  • 21
2
votes
0 answers

How to tell astyle to do nothing?

I want to apply only one formatting rule from pletora of astyle capabilities - and nothing else. However, I find it impossible to turn off all astyle options - no matter what, I end up with aweful lot of undesired formatting changes. How to tell…
Alex Alex
  • 121
  • 2
2
votes
1 answer

Astyle code formatting

I'm writing a linux kernel module, and trying to use astyle to help me follow the coding standard. It seems to be formatting a spi_driver structure incorrectly and I'm wondering if anyone knows why. This is the code before passing to astyle (with…
Woodrow Douglass
  • 2,605
  • 3
  • 25
  • 41
2
votes
1 answer

Astyle - how to format condition without braces to 1TBS

I have a program which uses Astyle to format the code into 1TBS. So, if I have a code like this if(condition) func(a, b); it changes to this if(condition) { func(a, b); } The problem is, when parameters in the called function are broken…
Eenoku
  • 2,741
  • 4
  • 32
  • 64
2
votes
0 answers

Indenting continuation lines with Artistic Style

Artistic Style indents these lines in a Java source file: WebDriver driver = new FirefoxDriver() .test() .full() .value(); like this: WebDriver driver = new FirefoxDriver() .test() .full() .value(); Is there a way to get a more…
Eleno
  • 2,864
  • 3
  • 33
  • 39
2
votes
1 answer

How do I break oneline if statement with astyle?

Somehow I don't like one line if statements like if (looks_ugly) please_break_this(); and want to turn them into this if (looks_ugly) please_break_this(); Can astyle do that for me? I can't find an appropriate option to astyle.
Igor S.K.
  • 999
  • 6
  • 17
2
votes
1 answer

How to reduce redundant spaces between keywords in C++ code using astyle

I always type more spaces between keywords, or between identifiers without awareness. How can I configure astyle configuration file to reduce them to only one space automatically? For example: int main(int argc, const char *argv[]) { …
JoJo
  • 1,377
  • 3
  • 14
  • 28
2
votes
1 answer

Astyle is adding new lines to the end of the file everytime

I just installed vim-autoformat and astyle to format my c/c++ code inside vim. Everything seems to work, but it puts a newline to the end of the file everytime I run it. Even if there is one (or multiple). I tried to find the option in astyle -h and…
Jakub Žitný
  • 962
  • 1
  • 9
  • 38
2
votes
2 answers

How to use Astyle on part of file

I'm using Astyle in Eclipse. I want to be able to use it on a part of a file, and not on an entire source file (e.g. to beautify only one function in the code, and not the entire source file). How do I do that? Thanks!
Yoss
  • 41
  • 1
  • 4
1
vote
1 answer

How do I create a makefile rule to run astyle?

I'd like to create a makefile rule to run astyle on any writable source files. Currently, I have a rule like the following: style: find . -perm -200 -regex ".*[.][CHch]p*" -exec astyle --suffix=none --style=ansi --convert-tabs "{}" \; This rule…
brianegge
  • 29,240
  • 13
  • 74
  • 99
1
vote
2 answers

How to run astyle over the list of files specified by git diff --name-only

Running git diff --name-only gives me a list of files like this file1 file2 Astyle usage goes something like this astyle.exe --options=myoptionsfile Instead of specifying each file manually I'd like a way to pipe the output of git…
Peter Kapteyn
  • 354
  • 1
  • 13
1
vote
1 answer

How can I terminate a file with a newline with Astyle?

I'd like to put a newline character to the end of a file if it is not terminated properly. Does Astyle have any option to do this?
bmann
  • 81
  • 6
1
vote
1 answer

Vim code formating with astyle (formatprg in vimrc)

I'm trying to use astyle as my code formatter in Vim. However, I can't seem to find how to tell vim which options to use for astyle. The following is in my vimrc: autocmd BufNewFile,BufRead *.cpp set formatprg=astyle\ If given no options in command…
A.D
  • 427
  • 1
  • 4
  • 12
1
vote
1 answer

Astyle formatting for vscode: extension doesn't have a config file

I am trying to get https://marketplace.visualstudio.com/items?itemName=chiehyu.vscode-astyle to work (if anyone has a different extension or settings I can use, I am all ears). I cannot find a config file for it, even though the page implies that…
Daniel Paczuski Bak
  • 3,720
  • 8
  • 32
  • 78