Thread: setting indentation in dev-c++

  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    100

    setting indentation in dev-c++

    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.
    Code:
    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??

  2. #2
    Registered User
    Join Date
    Mar 2006
    Posts
    725
    Tools -> Editor Options -> Auto Indent.
    Code:
    #include <stdio.h>
    
    void J(char*a){int f,i=0,c='1';for(;a[i]!='0';++i)if(i==81){
    puts(a);return;}for(;c<='9';++c){for(f=0;f<9;++f)if(a[i-i%27+i%9
    /3*3+f/3*9+f%3]==c||a[i%9+f*9]==c||a[i-i%9+f]==c)goto e;a[i]=c;J(a);a[i]
    ='0';e:;}}int main(int c,char**v){int t=0;if(c>1){for(;v[1][
    t];++t);if(t==81){J(v[1]);return 0;}}puts("sudoku [0-9]{81}");return 1;}

  3. #3
    Registered User
    Join Date
    Jan 2006
    Posts
    100
    I already have that selected, but it doesn't change anything.

  4. #4
    Moderately Rabid Decrypt's Avatar
    Join Date
    Feb 2005
    Location
    Milwaukee, WI, USA
    Posts
    300
    What is your tab size set to?
    There is a difference between tedious and difficult.

  5. #5
    Registered User
    Join Date
    Jan 2006
    Posts
    100
    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:

    Code:
    for()
    
    {
    
    printf();
    
    }
    or this:

    Code:
    for()
    
    {
            printf();
    
                           }
    And the closing brace for main() stays in the middle of the page.

  6. #6
    Registered User Dante Shamest's Avatar
    Join Date
    Apr 2003
    Posts
    970
    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

  7. #7
    Registered User
    Join Date
    Jan 2006
    Posts
    100
    That's alot better.

    Code:
    #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.

  8. #8
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901
    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?

  9. #9
    Registered User
    Join Date
    Jan 2006
    Posts
    100
    Yeah, but other compilers do it automatically when you type certain keywords.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. New to Dev C++/<windows.h>...
    By Cilius in forum C++ Programming
    Replies: 3
    Last Post: 02-23-2005, 01:05 AM
  2. Glut and Dev C++, Programs not Quitting?
    By Zeusbwr in forum Game Programming
    Replies: 13
    Last Post: 11-29-2004, 08:43 PM
  3. Dev C++ Compiler, Indentation?
    By Zeusbwr in forum C++ Programming
    Replies: 3
    Last Post: 10-21-2004, 06:13 AM
  4. openGL programming - From MSVC++ to Dev C++
    By WDT in forum Game Programming
    Replies: 1
    Last Post: 03-08-2004, 05:19 PM
  5. Your favourite fantasy game setting?
    By fry in forum Game Programming
    Replies: 4
    Last Post: 10-16-2002, 06:26 AM