On Jul 19, 2006, at 12:21 PM, James Edward Gray II wrote:
Yep. Push control-< before you type a word. ;)
Both modes are handy in different situations. Worth getting the hang of.
I further suggest studying the command that does this trick. Here is the code for it, with comments removed:
#!/usr/bin/env ruby single_no_arg = /^(?:br|hr)$/i single = /^(?:img|meta|link|input|base|area|col|frame|param)$/i print case tag = STDIN.read when single_no_arg then "<#{tag} />" when single then "<#{tag} $1/>" when '' then "<${1:p}>$2</${1/\s.*//}>" else "<#{tag}>$1</#{tag.strip[/^\S+/]}>" end
It is set to output "Insert as snippet". This means that the various strings to be printed that we see above should be interpreted as snippets. The one relevant for us here is: "<${1:p}>$2</${1/\s.*//}>"
when that snippet is in action, anything you type in the <${1:p}> part gets copied at the closing snippet as well, except that everything from the first space and no is substituted by nothing (that's what the ${1/\s.*//} does, see http://macromates.com/ textmate/manual/snippets#transformations ).
So you would do ctrl+<, followed by typing 'span' , then space, and then the class stuff. On the closing tag only the 'span' part will appear. When you are ready to type the things in the tag, press tab.
And of course, you could write your own span snippet that does some more specialized behavior. The bundle already has a bunch of example snippets.
James Edward Gray II
Haris