[TextMate] Feature - managing the snippets

Mats Persson mats at imediatec.co.uk
Fri Oct 15 11:53:01 UTC 2004


On Oct 14, 2004, at 21:59, profprof at mac.com wrote:

> This sounds like an elegant solution. It would give much more 
> flexibility to the system. As was suggested by somebody on the Wiki 
> page, this could be combined with a classification.

I believe the above mentioned suggestion was made by me, so I should 
comment on it further.


> So, if in Latex, I want to generate a table, I type:
>
>       table[tab]
>
> If I wanted to include an HTML snippet in Latex mode, then I might 
> type:
>
>      html:table[tab]
>
> If the command is not found in Latex, and only in another mode, then 
> it is found without having to specify the type.

Ideally the 'joiner' character between  "html" and "table[tab]"  in the 
above examples should be a single key stroke, rather than the ' : ' 
which is a two-key keystroke. Although looking through the keyboard I 
don't find many good candidates.


The way I see things, perhaps wrongly so, is that each user can create 
their default bundle that contains all the common language syntax files 
that they use on a regular basis.

In my case these would primarily be: HTML, PHP, CSS and JavaScript

So in the Snippets folder - and Snippets editor window - there would 
ideally be a sub-directory/grouping called:
HTML => for html based snippets
PHP  => for PHP related snippets
CSS => for CSS related snippets
JS => for JavaScript related snippets


Since the HTML syntax file is the host file - that embeds the other 
language syntaxes - this would be the default syntax for a .html file, 
and TM would (hopefully) know what mode we are currently in where the 
cursor is, and therefore by typing:

	table[tab]

while in HTML mode would collect the "table" snippet from the HTML 
directory/grouping, even though we may have a snippet by that name in 
each of our sub-dirs/groupings.

IF we for some reason would wish to override the default action, then 
we can type:

PHP:table[tab]   or  <groupingID>:< snippetName>


My ideal scenario would be to have a structure something like the 
following:

Snippets/
	/HTML/
		/div/
			header	=	basic HTML snippets
			footer
			sidebar

	/PHP/
		/div/
			header	=	basic HTML & PHP snippets
			footer
			sidebar

If we had the above we would type:

	php:div:header	to collect the header snippet in the div grouping in 
the php grouping.


Why would I want to have it like this ??  Well, I have found that 
developing web sites I use similar snippets of code but with varied 
elements inside, so by having the ability of having multiple snippets 
in sub-groups we can have a snippet group for each type of project we 
are working on. In one project we may use a simple header div with just 
a simple logo text in there, whereas in another project we might have a 
lot more information in there.


Just my 2 pence worth : )


Kind regards,

Mats




More information about the textmate mailing list