Tapatalk

Turning off auto indent on RETURN of a line with an IF condition in C/C++

Turning off auto indent on RETURN of a line with an IF condition in C/C++

7
NewbieNewbie
7

    Apr 20, 2010#1

    Can't seem to find an answer.

    I am using the auto-indent feature (Configuration->Editor Display->Formatting->Auto indent new lines). I would like to change the number of tabs/spaces that the auto-indent uses.

    For example, I want this:

    Code: Select all

        if( 1 == 2 )
        {
            do_stuff( );
        }
    Instead of this:

    Code: Select all

        if( 1 == 2 )
            {
            do_stuff( );
            }
    My auto-indent settings produce the 2nd code clip. How can I change this?

    Thanks.

    6,685587
    Grand MasterGrand Master
    6,685587

      Apr 21, 2010#2

      When you have a file open and active, open Advanced - Configuration - Editor Display - Syntax Highlighting. The language for the active file is already preselected. Click on button Open to open the wordfile containing the syntax highlighting language used for the active file. Close the configuration dialog with button Cancel.

      Go to the line starting with /Indent Strings = which is in standard wordfile c_cplusplus.uew:

      /Indent Strings = "{" "if" "else" ":"

      According to the small example you posted I suggest to change the line to

      /Indent Strings = "{" ":"

      which is enough for your coding style. "if" and "else" are for programmers coding your example as:

      Code: Select all

      if( variable < 5 )
         // single command
      else
         // other single command
      The ":" is for

      Code: Select all

      switch( var )
      {
         case 1:
            // commands
            break;
         case 2:
            // commands
            break;
         default:
            // commands
            break;
      }
      You can remove ":" also from the indent strings definition if your are coding switch statements (normally) as follows:

      Code: Select all

      switch( var )
      {
         case 1:  // commands
                  break;
         case 2:  // commands
                  break;
         default: // commands
                  break;
      }
      Best regards from an UC/UE/UES for Windows user from Austria

      7
      NewbieNewbie
      7

        Apr 21, 2010#3

        Thank you, this worked.

        Is there an online how-to for editing word files? The UE help file is rather brief.

        Also, one minor question. It seems that I need to close and restart UE for wordfile changes to take affect. Is there a way to refresh UE without restarting it?

        Thanks.

        6,685587
        Grand MasterGrand Master
        6,685587

          Apr 21, 2010#4

          Lots of additional information about editing wordfiles can be found in syntax highlighting forum
          Most of the definitions in a wordfile opened and edited in the same instance of UltraEdit as an opened example file are applied immediately after saving the modified wordfile and switching focus to the example file. That includes all words in the up to 8 color groups, string highlighting, comment highlighting, highlighting with marker characters, function strings, ...

          Not automatically applied after modification are currently (UE v16.00.0.1038) changed code folding strings. An action which forces the code folding engine to rescan the active file like
          • closing the active example file and re-opening it via the recent file list,
          • or using File - Revert to Saved,
          • or selecting temporary another language for highlighting or No Highlighting in menu View - View as (Highlighting File Type)
          results in updated code folding information in the gutter. I suppose that for changes on the indent strings the same methods can be used.
          Best regards from an UC/UE/UES for Windows user from Austria