I'm using version 17.12 of C::B, which I believe is the most current version and I am having trouble formatting my brackets.
Code written in the GNU bracket style is supposed to look like this:
int Foo(bool isBar)
{
if (isBar)
{
bar();
return 1;
}
else
return 0;
}
But instead, my code auto-formats to this:
int Foo(bool isBar)
{
if (isBar)
{
bar();
return 1;
}
else
return 0;
}
I've tried tweaking dozens of settings in the Configure Editor menu and the Source Formatter, but can't figure out how to get this to work.
Are you using the "Format use Astyle" context menu command? Or do you expect the format to be preserved during normal editing?
I'm not sure I understand your question. What is the "Format use AStyle" context menu? What I did was go into setting>editor>Source Formatter and selected GNU from the panel on the left. I guess what I am trying to do is configure my editor so that it formats to the selected style in real time, as I am typing out the code. Is that a possibility in Code::Blocks? Also, I don't know if this is relevant, but the plugin menu says I have Source code formatter (AStyle) 2.05.1 enabled.
(https://i.postimg.cc/vTBMqqXT/Screenshot_15.png) (https://postimages.org/)application screenshot (https://postimages.org/app)
Quote from: 93NickCousar on September 23, 2018, 02:06:17 AM
What is the "Format use AStyle" context menu?
Right click in an editor and you'll see it.
I don't think codeblocks supports this formatting during editing unfortunately.
I am using that all the time while editing, but its only almost-realtime by pressing Alt-A (Windows only, just saw that in Linux that did not work).
This shortcut key actually formats your whole code in the current window, i.e. the whole file according to what style you have selected. It works quite well once I got used to pressing Alt-A all the time (a bit like pressing Ctrl-S all the time)
For exampe
if(i==1) a=1;
else a=2;
looks like that after pressing Alt-A
if (i==1)
{ a=1; }
else
{ a=2; }
With your GNU style it would be a bit different.
Not sure if that answers the question, though
@tigerbeard That does answer my question. C::B is free after all, so I guess the alt-a is good enough.