[TxMt] Javascript method snippet

Mike Ter Louw mterlo1 at uic.edu
Sun Feb 19 03:31:41 UTC 2006


Hi,

I just wanted to post a nice snippet I just made...er, actually I just
ripped it from the fun (function) snippet.  It goes like this:

prototype.${1:method_name} = function(${2:first_argument}) {
	${0:// body...}
};

I have it set up to expand on proto<tab>.  Actually, after thinking
about it, maybe this would be better:

${1:class_name}.prototype.${2:method_name} = function(${3:first_argument}) {
	${0:// body...}
};

Either way, I think this is really useful because like all good snippets
it keeps you from typing a bunch of stuff that is always the same, and
it keeps you from forgetting the trailing semicolon (which the fun
snippet and auto-close brace omit).

Any chance on getting something like this included with Textmate out of
the box?  Forgive me if this has already been discussed; a quick search
on the list and wiki didn't turn up anything on this subject.

Also, the fun snippet that's included uses "# body..." instead of "// 
body...".  Is this intentional, or was the hash just forgotten when 
porting the snippet from another language?

Mike




More information about the textmate mailing list