Author Topic: Code::Blocks Auto Format?  (Read 4054 times)

Offline Goodkind

  • Newcomer
  • *
  • Posts: 2
Code::Blocks Auto Format?
« on: February 10, 2012, 09:25:09 pm »
Hello,

I have noticed that Code::Blocks will do some auto formating when entering a open bracket on a new line.   The closing bracket is automaticly placed two lines down and the cursor is one line down and indented.

I've gone through the manual and found Astyle.  After some expermentation and some reading on the forums it appears that is only for formating code that is already all typed out.

Is there a way to change the default behavior of the opening bracket?  My format style is slightly different.  What I do is:

While(true){
    statement block
}

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1399
Re: Code::Blocks Auto Format?
« Reply #1 on: February 16, 2012, 04:24:59 am »
From what I can tell, Code::Blocks is simply trying to guess your style from how you type; try typing:

while(true){

then pressing enter.  For me, this produces the following:
Code: [Select]
while(true){
    |
}
(The pipe "|" symbol being the new location of the cursor.)

Does Code::Blocks do something different on your computer?

(By the way, sorry, it appears your post got lost.)

Offline WantCbPersonalized

  • Newcomer
  • *
  • Posts: 6
Re: Code::Blocks Auto Format?
« Reply #2 on: October 13, 2012, 10:19:44 pm »
The same thing happens to me, as Goodkind said, and my style is like his. To me is not happening the same as for you, Alpha, if i press enter when you say the } goes the next line WITHOUT indentation like it used to happen in 8.02. What setting have you made to happen like that to you? I am very curious.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 8695
Re: Code::Blocks Auto Format?
« Reply #3 on: October 14, 2012, 07:38:20 am »
What setting have you made to happen like that to you? I am very curious.
I'd say: enable smart indenting...?! Did you try the related editor options already?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline WantCbPersonalized

  • Newcomer
  • *
  • Posts: 6
Re: Code::Blocks Auto Format?
« Reply #4 on: October 14, 2012, 09:38:13 am »
If you refer to trying all the possible combinations that are available in setting, yes I have done that. Also, Setting - Editor - Source formatter seems to affect the code only when you manually format it with AStyle, and this works only if the code is already written. I have attached a screenshot with General setting from editor. One more thing, Source Formatter in setting is set to banner, that is how I like my code to be. I've tried custom, but no big difference happens, or I may be missing something. The "smart" thing seem to happen in a different way.

while(true)
|

now, if I type "{" the following thing will happen:

while(true)
{
    |
}

this is good, but I was wondering if it could happen the way Alpha says. If I do like he said:

while(true){|}

now press Enter

while(true){
|}

Am I missing something? If I disable brace completion:

while(true){|

now Enter

while(true){
    |

[attachment deleted by admin]

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 6666
    • Jens unofficial debian-repository for the Code::Blocks - IDE
Re: Code::Blocks Auto Format?
« Reply #5 on: October 14, 2012, 10:06:01 am »
Which version of C::B do you use ?
Regards

Jens  Debian - nightlies (and release) : http://apt.jenslody.de/ Fedora [18 - 20]- and CentOS/RedHat [5, 6 & 7] - nightlies : http://rpm.jenslody.de/

Offline WantCbPersonalized

  • Newcomer
  • *
  • Posts: 6
Re: Code::Blocks Auto Format?
« Reply #6 on: October 14, 2012, 10:08:02 am »
10.05 with all plugins

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 6666
    • Jens unofficial debian-repository for the Code::Blocks - IDE
Re: Code::Blocks Auto Format?
« Reply #7 on: October 14, 2012, 10:37:00 am »
Regards

Jens  Debian - nightlies (and release) : http://apt.jenslody.de/ Fedora [18 - 20]- and CentOS/RedHat [5, 6 & 7] - nightlies : http://rpm.jenslody.de/

Offline WantCbPersonalized

  • Newcomer
  • *
  • Posts: 6
Re: Code::Blocks Auto Format?
« Reply #8 on: October 14, 2012, 11:18:02 am »
I currently do not know what a nightly build is, but I will search a lot and come up with a response. :-\