User forums > Using Code::Blocks

curly braces and auto indent

(1/3) > >>

lewashby:
I'm tying to decide between codeblocks, Eclipse, and Geany. When using codeblocks after I type the fist curly brace '{' codeblocks creates another one for me but leaves them both on the same line. After placing the cursor between the two braces '{}' and hitting Enter it drops the second curly brace '}' to the next line but fails to auto indent my cursor position to one tab between the position of the two curly braces. I have looked at the settings  under -> Source formatter -> Style, Indentation, & Formatting. -> General settings, -> and Code completion. Each time I think I have found the right setting and make the appropriate changes I see no affect after returning to codeblocks.

Example

int main()
{} // after pressing enter between these two I should get what's below

int main()
{
    //cursor here
}

Jenna:
Play with the settings in "Settings -> Editor -> General settings -> Editor settings -> Indent options".
I have checked all of them, except the last one ("Select brace completion").

lewashby:
I'm still not getting a good result. Have to manually press ENTER twice between the {} curly brackets and then bring the cursor up and hit TAB.

ollydbg:

--- Quote from: lewashby on February 07, 2015, 06:19:26 am ---I'm still not getting a good result. Have to manually press ENTER twice between the {} curly brackets and then bring the cursor up and hit TAB.

--- End quote ---
I can't reproduce this issue. Do you check the options Jens' said?

--- Quote from: jens on February 05, 2015, 10:05:30 pm ---Play with the settings in "Settings -> Editor -> General settings -> Editor settings -> Indent options".
I have checked all of them, except the last one ("Select brace completion").

--- End quote ---

In my C::B.
I first enter this.

--- Code: ---int main()

--- End code ---
Then I hit enter, I get my caret to the second line.
Then, I enter a '{', and the code becomes:

--- Code: ---int main()
{
    //* note that the caret was automatically placed here
}
--- End code ---
So, I don't need to press Enter again.  ;)

nightlight:
I have used CB 10.5 until upgrading to the latest 13.12 version and my indents in Whitesmith mode are broken too.
This is how the sample is supposed to look like:

--- Code: ---int Foo(bool isBar)
  {
  if (isBar)
    {
    bar();
    return 1;
    }
  else
    {
    return 0;
    }
  }

--- End code ---

In the old CB, as soon as I typed Enter after if (isBar) the open brace was inserted at indent +2, the closing brace would be appear aligned 2 lines below it, with empty line & cursor ready right below the open brace (at same column) for the block in between.

In the new version, typing the same way, the code ends up looking like this, as if forcing some other source formatting style (with braces not aligned with the block between them), not Whitesmith:


--- Code: ---int Foo(bool isBar)
{
  if (isBar)
  {
     bar();
     return 1;
  }
  else
  {
     return 0;
  }
}

--- End code ---

In the general settings for indentation I have checked on: Autoindent, Smart Indent, Brace Completion, Backspace unindents, Brace Smart Indent, Selection brace completion.

Navigation

[0] Message Index

[#] Next page

Go to full version