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

General and specific configuration/INI settings

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

Postby 3JB » Tue Apr 20, 2010 2:27 pm

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.
3JB
Newbie
 
Posts: 7
Joined: Thu May 21, 2009 8:23 am

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

Postby Mofi » Wed Apr 21, 2010 12:12 am

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;
}
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4058
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

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

Postby 3JB » Wed Apr 21, 2010 7:38 am

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.
3JB
Newbie
 
Posts: 7
Joined: Thu May 21, 2009 8:23 am

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

Postby Mofi » Wed Apr 21, 2010 8:57 am

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.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4058
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna


Return to Configuration/INI Settings