how to automatically close quotes, brackets, braces

This forum is user-to-user based and not regularly monitored by IDM.
Please see the note at the top of this page on how to contact IDM.

how to automatically close quotes, brackets, braces

Postby jamie.echlin » Thu Oct 05, 2006 9:50 am

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
User avatar
jamie.echlin
Newbie
 
Posts: 2
Joined: Wed Oct 04, 2006 11:00 pm

Re: how to automatically close quotes, brackets, braces

Postby Mofi » Fri Oct 06, 2006 2:32 pm

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.

  1. Enter at Advanced - Configuration - Directories - Template Directoy 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.
  2. Open Advanced - Display/Modify Templates.
  3. Enter a template name like "Double Quotes".
  4. Enter in the big text field "^".
    Press key F1 to see help about templates for details and the special meaning of ^ in templates.
  5. Select the next free template number.
  6. Repeat steps 3-5 for brackets and braces.
  7. Press the button OK to save the templates.
  8. Open Advanced - Configuration - Key Mapping and scroll down in the list of commands to InsertTemplate0.
  9. Remove the existing key assignment and assign " to it.
  10. Redo the previous step also for [ and ( and {.
  11. 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.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4055
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: how to automatically close quotes, brackets, braces

Postby jamie.echlin » Fri Oct 13, 2006 8:57 am

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
User avatar
jamie.echlin
Newbie
 
Posts: 2
Joined: Wed Oct 04, 2006 11:00 pm

Re: how to automatically close quotes, brackets, braces

Postby Bego » Fri Oct 13, 2006 9:14 am

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
User avatar
Bego
Master
Master
 
Posts: 357
Joined: Wed Nov 24, 2004 12:00 am
Location: Germany

Re: how to automatically close quotes, brackets, braces

Postby Mofi » Fri Oct 13, 2006 9:57 am

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

Re: how to automatically close quotes, brackets, braces

Postby cjkawu » Sun Oct 15, 2006 7:00 pm

Mofi,
You are always so very helpful, I think you should change your uid to "FAQ!"
:lol:
cjkawu
Newbie
 
Posts: 2
Joined: Thu Oct 05, 2006 11:00 pm

Re: how to automatically close quotes, brackets, braces

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

Thanks!
3JB
Newbie
 
Posts: 7
Joined: Thu May 21, 2009 8:23 am


Return to UltraEdit General Discussion