HTML, auto-complete and snippets (was Re: [TextMate] (no subject))

Justin French justin.french at indent.com.au
Wed Oct 6 15:09:31 UTC 2004


On 07/10/2004, at 12:01 AM, mnothrop wrote:

> I'm afraid I find the auto-complete somewhat underwhelming; it seems 
> pretty basic, and (I think) belies it's simple pattern-matching basis 
> -- it doesn't display any knowledge of syntax (e.g. will suggest 
> 'body' in the context of a div tag, instead of 'border'), and is 
> strict in it's matching (will match 'cellS...' for cellSpacing, but 
> not 'cells...' -- oh, and hitting Escape each time isn't the most 
> ergonomic aspect of editing.

It's actually not auto-complete in the sense that it's not trying to 
guess what you want based on context (yet)... it's simply guessing what 
you want to type based on what you've already typed elsewhere in the 
document.  It suggested "body" because it appeared further up the page. 
  It possibly would have suggested border as a second option if you'd 
typed border elsewhere.

Personally, I don't mind hitting escape a few times to find what I want.

Instead of auto-complete, I've become fond of the "Make HTML Tag 2" 
Macro, which takes the current word (eg div) and makes it into a tag.

> ...but of course, at the moment, you've got to do the heavy lifting! 
> It would take some time to enter a useful set of snippets, but I've 
> started... If anyone else has, we must share!

I shared everything I could come up in the few hours left before 1.0 
was released (most of the snippet menu)... I expect that most people 
will delete my defaults and start creating their own, which work the 
way they want to work... after all, that's what TM does :)

> I own skEdit, and really like it's auto-complete feature, which you 
> might consider more traditional, in that it's implemented similarly to 
> other apps (e.g. Dreamweaver, HomeSite); it suggests the likely tag 
> *as* you type, with a drop down menu that is likewise filtered in 
> real-time.

I hate those things, but I think something like this is planned for 
later on.

> In comparing the features you quickly see that skEdit's approach 
> augment's the user's knowledge and memory of syntax (either 
> reminding/reinforcing, or teaching), whereas TM requires a mental 
> mapping of not only specifics of syntax, but an additional aspect, in 
> the triggers. It may just be my perspective on this feature (i.e. 
> largely reliably, and strict syntax of HTML, vs. highly variable, 
> creative arrangements of syntax in programming languages,) but I don't 
> find this approach as convenient for X/HTML editing.

I think the point is that you re-shape TM to suit what you want... it's 
the perfect (and better) mental model to "become one" with your editor. 
  Write a snippet you need, attach it to a trigger that seems natural to 
YOU, and smile :)

> Having said that, once I had a full compliment of HTML snippets, 
> defining my coding standards (e.g. always include certain attributes, 
> like class, id etc.), I could see it feeling more efficient... I guess 
> the problem becomes finding the balances between these two different 
> approaches, but the way I envisage it, my snippent menu will go on for 
> ever!

Exactly -- and it will be YOURS, to suit the way YOU work :)

Justin




More information about the textmate mailing list