PDA

View Full Version : setting indentation in dev-c++



richdb
06-07-2006, 07:43 PM
I know this has been covered before, but I can't get dev-c++ to do indentation. I have tried the obvious things like: Tools, editor options. But whatever I try, I can't get it to do decent indentation.
By default, it makes things look like your writing in MS Word.


if(x)

{

printf();

}

And the closing brace for the body of main() never wraps around like other compilers. Anyone know how to set this stuff??

jafet
06-07-2006, 08:14 PM
Tools -> Editor Options -> Auto Indent.

richdb
06-07-2006, 08:18 PM
I already have that selected, but it doesn't change anything.

Decrypt
06-07-2006, 09:00 PM
What is your tab size set to?

richdb
06-10-2006, 08:22 AM
It is set to 2. But playing with it doesn't seem to help. The code doesn't indent in the places it should, and braces don't wrap correctly either. When I write a loop, it comes out looking like this:



for()

{

printf();

}


or this:



for()

{
printf();

}


And the closing brace for main() stays in the middle of the page.

Dante Shamest
06-10-2006, 08:49 AM
Here are my settings that seem to work okay for me.

Auto Indent: checked
Use Tab Character: not checked
Smart Tabs: not checked
Keep Trailing Spaces: checked
Backspace Unindents: checked
Enhanced Home Key: checked

richdb
06-10-2006, 10:59 AM
That's alot better.



#include <stdio.h>

main()

{
int a=2,
b=10,
c=1,
d=5;

while(a < b)

{
printf("\ntest");
++a;
}

if(a==b)
{
printf("\n\ntest2");
--a;
}

else
{
++c;
++d;
}
getchar();

}But as you can see, the declarations of int don't line up, and the "else" part doesn't indent after the "if". Maybe these things can't be changed, I'm just used to using visual studio where the formating and indentation was automatic and comfortable. Here you get that left justified look on everything.

indigo0086
06-12-2006, 10:03 AM
Wasn't there a way to select a block of code and press tab or shift tab and it changes the entire indent for that block?

richdb
06-12-2006, 08:03 PM
Yeah, but other compilers do it automatically when you type certain keywords.