User forums > Using Code::Blocks
How to configure the Source Formatter for GNU Bracket Style
93NickCousar:
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:
--- Code: ---int Foo(bool isBar)
{
if (isBar)
{
bar();
return 1;
}
else
return 0;
}
--- End code ---
But instead, my code auto-formats to this:
--- Code: ---int Foo(bool isBar)
{
if (isBar)
{
bar();
return 1;
}
else
return 0;
}
--- End code ---
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.
oBFusCATed:
Are you using the "Format use Astyle" context menu command? Or do you expect the format to be preserved during normal editing?
93NickCousar:
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.
application screenshot
oBFusCATed:
--- Quote from: 93NickCousar on September 23, 2018, 02:06:17 am ---What is the "Format use AStyle" context menu?
--- End quote ---
Right click in an editor and you'll see it.
I don't think codeblocks supports this formatting during editing unfortunately.
tigerbeard:
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
Navigation
[0] Message Index
[#] Next page
Go to full version