how to automatically close quotes, brackets, braces

how to automatically close quotes, brackets, braces

2

    Oct 05, 2006#1

    hi - i'm sure this is a simple problem, but haven't found the answer in the options or wordlist file. Like Eclipse, how do I enter a " or { or (, and have UE close it for me and insert the cursor between the two?

    thanks a lot, ,jamie

    6,684586
    Grand MasterGrand Master
    6,684586

      Oct 06, 2006#2

      Not supported directly by UltraEdit. UEStudio has such a feature with IntelliTips (Configuration - IDE - IntelliTips - Miscellaneous).

      In UltraEdit you can use templates to do this.
      • Enter at Advanced - Configuration - Directories - Template Directory where the template file Uetmplte.dat should be stored which is created by the next steps. Save the setting with OK.
        Note: This step is not required for UE v14.00 and later when working with an environment other than the default Advanced used only when upgrading from a previous version without using one of the standard environments or a customized environment. Each environment has its own template file named environment name.te1.
      • Open Advanced - Display/Modify Templates.
      • Enter a template name like "Double Quotes".
      • Enter in the big text field "^".
        Press key F1 to see help about templates for details and the special meaning of ^ in templates.
      • Select the next free template number.
      • Repeat steps 3-5 for brackets and braces.
      • Press the button OK to save the templates.
      • Open Advanced - Configuration - Key Mapping and scroll down in the list of commands to InsertTemplate0.
      • Remove the existing key assignment and assign " to it.
      • Redo the previous step also for [ and ( and {.
      • Save the modified key assignments with OK.
      Now when you press " or [ or ( or { automatically the matching closing char is also inserted and the cursor is set between it. However, this solution is not intelligent because it always inserts the matching closing char even if the matching brace for example is already present. If you only want the opening char now you have the delete the closing char always with key DEL.

      Please note: I have not tested what I have written here and I use templates for other things and not for that purpose you want.
      Best regards from an UC/UE/UES for Windows user from Austria

      2

        Oct 13, 2006#3

        Thanks for that Mofi, it works pretty well.

        My only gripe is that it should be language-aware somehow, so that it doesn't put in the template if you type \", and it shouldn't do it if you are closing a quoted string. Guess that is a RFE.

        thanks again, jamie

        344
        MasterMaster
        344

          Oct 13, 2006#4

          Hi dudes,

          One more idea from me, where you can determine, if you want, say, only one { or a {} with cursor in between.
          Write a macro for each "key" and bind it to your "ctrl-{" key.
          Do this for ( and [ and whatever too.
          Each macro looks like that (I named it "quoted{" ):

          Code: Select all

          InsertMode
          ColumnModeOff
          HexOff
          "{}"
          Key LEFT ARROW
          
          You see ? Now if you press ctrl-{ you will have what you want.
          Simple but good enough for me.

          hth, Bego
          Normally using all newest english version incl. each hotfix. Win 10 64 bit

          6,684586
          Grand MasterGrand Master
          6,684586

            Oct 13, 2006#5

            Yes, with automatically loaded macros you can make it more language dependent. Example for the double quotes:

            IfExtIs "cpp"
            Else
            IfExtIs "c"
            Else
            IfExtIs "h"
            Else
            """
            EndIf
            EndIf
            EndIf
            InsertMode
            ColumnModeOff
            HexOff
            IfColNumGt 1
            Key LEFT ARROW
            IfCharIs "\"
            Key RIGHT ARROW
            """
            ExitMacro
            EndIf
            Key RIGHT ARROW
            EndIf
            """"
            Key LEFT ARROW

            I have not tested the macro above. Hope it works.

            But much more is not possible. That's the reason why the feature is available only in UEStudio with its IntelliTips support. IntelliTips analyzes the code language dependent.
            Best regards from an UC/UE/UES for Windows user from Austria

            2
            NewbieNewbie
            2

              Oct 16, 2006#6

              Mofi,
              You are always so very helpful, I think you should change your uid to "FAQ!"
              :lol:

              7
              NewbieNewbie
              7

                Apr 21, 2010#7

                Thanks!