User forums > Help

Indenting 8 spaces

(1/3) > >>

korwynkim:
Hi. Whenever I open a brace and press enter to go to a new line, Code Blocks indents 8 spaces instead of 4. This doesn't happen with functions, only if, while, for etc. If I turn smart indent off, the closing brace won't automatically move to the correct position.

oBFusCATed:
Do you have exact reproduction steps?
I've seen this problem, but I think it doesn't happen all the time.

Jenna:
I get this behaviour, if I start a while-loop with the opebning brace in the same line as the while-statement and decide later to put it into the next line, by placing the caret in front of the opening barce and pressing enter.
This only happens, if the next line was auto-indented.
Steps to reproduce:

* I have all indent options enabled,
* I write while(1),
* I add an opening brace,
* a closing brace is automatically added, the caret is between both braces,
* I press Enter, the closing brace is moved two lines below the while-statement, the caret is placed in the line between and indented automatically 4 spaces (seen from
* the while keyword and/or the closing brace,
* I place the caret if front of the opening brace and press Enter,
* the opening brace is moved to the next line with wrong indentation.

korwynkim:
It only seems to happen with control structures. I don't have brace completion enabled. If i put an opening brace on the same line as the control statement and press enter, the caret will be indented 8 spaces on the next line. This only happens the first time. If I go back to the opening brace and press enter, the caret indents correctly.

thomas:
It's intended behaviour to double-indent the line following an opening brace, if "smart indent" is enabled. The closing brace is unindented once you hit return. This is meant to make typing code easier without you having to remember to indent each line properly. (Works 100% good for me every day, too. Trust me, if it didn't then I'd be puking.)

If you don't like this happening, disable "smart indent".

Of course, having "spaces instead of tabs" enabled is another matter. This is the in my opinion worst possible misconfiguration you can have (and unluckily the default, too). Maybe in 20 or 30 years from now, people will have learned that a tab and 4 space characters are not the same, and that spaces are not for indenting.

Navigation

[0] Message Index

[#] Next page

Go to full version