Tapatalk

Indenting Starting on the Indent String

Indenting Starting on the Indent String

1
NewbieNewbie
1

    May 22, 2007#1

    I'm currently using Ultra-Edit 32 v12.10a to write C++ code, and I have the following lines in my wordfile.txt file:

    Code: Select all

    /Indent Strings = "{"
    /Unindent Strings = "}"
    This provides me with automatically indented code that looks like the following:

    Code: Select all

    void blahblahdeblah()
    {
        if (blahblahagainblah)
        {
            asdfasdf();
        }
        haveacow();
    }
    This is all well and good, but I've just been handed a project where I need to have the braces indented to match the enclosing code. This means the previous code should appear as follows:

    Code: Select all

    void blahblahdeblah()
        {
        if (blahblahagainblah)
            {
            asdfasdf();
            }
        haveacow();
        }
    I've been looking all over the place, including this forum, for information on how to do this, and the closest I can get is to use the external Artistic Style application to range over my code and redo it. I'd much rather have this done as I go.

    Is there something I can set to have the indention level done starting with the indent string, rather than the line after it? Thanks.

    Me

    236
    MasterMaster
    236

      May 22, 2007#2

      One way that I can think of:

      If you remove the braces from the (un)indent strings list and instead use "if" "void" "while" etc. etc. as indent strings, then you'll get the indentation this way. You'll have to "outdent" manually, though.

      Any other ideas?

      30
      Basic UserBasic User
      30

        May 23, 2007#3

        I am trying, but I can't help myself... Troll alert:

        Maybe that GNU style should just be banned?

        6,685587
        Grand MasterGrand Master
        6,685587

          May 23, 2007#4

          A possible solution for GNU indenting style is to turn of auto-indent partly for C/C++ with empty indent and unindent strings in the syntax highlighting wordfile and write 2 macros in an automatically loaded macro file with hot keys assigned to the keys used to normally insert a { or }.

          The macro can than make the indent and unindent job on pressing of key { or }. Something like that for inserting a { (with real tabs for indenting):

          InsertMode
          ColumnModeOff
          HexOff
          IfExtIs "c"
          "tab{
          "
          ExitMacro
          EndIf
          IfExtIs "cpp"
          "tab{
          "
          ExitMacro
          EndIf
          "{"

          Note: tab must be a real tab character.

          And something like that for inserting a } :

          InsertMode
          ColumnModeOff
          HexOff
          IfExtIs "c"
          IfColNumGt 1
          Key LEFT ARROW
          IfCharIs 9
          Delete
          Else
          Key RIGHT ARROW
          EndIf
          EndIf
          "}
          "
          ExitMacro
          EndIf
          IfExtIs "cpp"
          IfColNumGt 1
          Key LEFT ARROW
          IfCharIs 9
          Delete
          Else
          Key RIGHT ARROW
          EndIf
          EndIf
          "}
          "
          ExitMacro
          EndIf
          "}"
          Best regards from an UC/UE/UES for Windows user from Austria