Snippets support

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.

Re: Snippets support

Postby Mofi » Thu May 14, 2009 3:55 am

Since UE v14.00 you can use environments. With environments you don't have anymore only 1 template file. Every environment has it's own template file (*.te1). So it is possible for example to switch the environment for a HTML project to a C/C++ project and use C/C++ templates instead of the HTML templates.

The auto-complete feature can be already configured to work based on the file extension. So it is possible to create strings for being fast inserted into the file using auto-complete. The auto-complete feature is just a little bit limited. You can specify a long string, but not a multi-line string. It is not possible to insert an auto-complete string around a current selection or specify the cursor position after inserting a string.

However, with macros and scripts you can "code" your own fully customized "snippet" support. It's up to you how powerful and smart that macros or scripts work to help you working more efficient.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4058
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Snippets support

Postby rpardee » Wed May 27, 2009 4:00 pm

The proposed workarounds are not substitutes for actual textmate/e style snippets. They all involve mousing around to find the particular chunk of text desired from a pick list. Snippets use the context of both the file extension and the text in the vicinity of the cursor to figure out what's called for, so your workflow isn't interrupted.

If I'm editing a ruby file and I type 'class' and then hit the tab key, the e text editor types out:

Code: Select all
class ClassName

end

The text 'ClassName' is highlighted, so that the next thing I type overwrites that w/the name I've chosen for the class. When I hit the tab key a second time, the cursor jumps down to the empty line before 'end', indented one level & ready for me to keep working. I never have to take my hands off the home row of the keyboard.

That's just one example--there are a ton of snippets defined in user-contributed bundles that do useful things like that.

To see a good demonstration of textmate snippets, see any of the railscasts, e.g., http://railscasts.com/episodes/73-complex-forms-part-1 .

Cheers,

-Roy
User avatar
rpardee
Basic User
Basic User
 
Posts: 14
Joined: Sun Sep 19, 2004 11:00 pm

Re: Snippets support

Postby Mofi » Thu May 28, 2009 2:24 am

So snippets in textmate are user-contributed macros/scripts/plugins for a particular language and not a core feature of textmate itself. Well, in UltraEdit you can write macros and scripts associated to hotkeys. I guess, especially a script can be programmed smart to get the same behavior as the snippet for Ruby in textmate.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4058
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Snippets support

Postby rpardee » Thu May 28, 2009 10:54 am

LOL--the way I would say it is that supporting bundles (which include snippets, syntax highlighting rules, and other stuff) is a core feature of e/textmate (e started out as a windows clone of textmate--you can use a textmate bundle in e w/only minor changes (line-endings, remove verboten chars from filenames)).

Many of the bundles are user-contributed, several were developed by the authors of textmate.

I definitely take your point about being able to macro my way to the same behavior. Is it possible to combine libraries of macros together and have them selectively activated depending on file extension? Is there already (or can we create) a clearinghouse for UE macro libraries? Having that sort of thing would encourage sharing I think.
User avatar
rpardee
Basic User
Basic User
 
Posts: 14
Joined: Sun Sep 19, 2004 11:00 pm

Re: Snippets support

Postby rhapdog » Thu May 28, 2009 5:13 pm

Widespread sharing of user macros and scripts would be a good thing to encourage.
User avatar
rhapdog
Master
Master
 
Posts: 265
Joined: Tue Apr 01, 2008 10:02 am
Location: Mississippi, USA

Re: Snippets support

Postby Mofi » Fri May 29, 2009 4:31 am

You can store multiple macros in one macro file. All my macro files contain multiple macros. You can specify 1 macro file to be automatically loaded. You can run a macro in an automatically loaded macro file by macro hotkey, by menu command Macro - Play Any/Multiple Times or by double clicking on a macro in the macro list view (View - Views/Lists - Macro List).

Better are scripts because you can add a nearly unlimited number of scripts to a script list which enables you to run every script by a script hotkey, from the menu Scripting or by double clicking on a script in the script list view (View - Views/Lists - Script List).

It is not possible to activate macro files or scripts depending on the file extension. But you can develop your macros or scripts to take the file extension into account and act accordingly. With this method you can assign a hotkey to a macro or script which does different things according to the file extension. You can see here a very simple macro used by me daily showing this technique.

Some users already contributed macros and scripts - see Downloads - Extras.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4058
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Previous

Return to UltraEdit General Discussion

cron