[TxMt] Snippet to change an HTML tag
Jed Hurt
jed.hurt at gmail.com
Sun Feb 25 15:21:02 UTC 2007
It works great. I learn something new every day. Thank you!
On 2/23/07, Charilaos Skiadas <skiadas at hanover.edu> wrote:
> On Feb 24, 2007, at 1:17 AM, Jed Hurt wrote:
> > This seems to happen quite often...
> > I have:
> > <h2>Download Our Catalog</h2>
> > Which needs to become:
> > <h3>Download Our Catalog</h3>
> > How would I go about writing a snippet/command that would allow me to
> > select "<h2>Download Our Catalog</h2>", activate the snippet, and have
> > the tag become selected ("h2" in this case) and mirrored in the
> > closing tag, therefore allowing me to simply type "h3" and then tab
> > back out?
>
> Put the following three lines in the command text, and set the
> command to input "selected text or line" and output "insert as
> snippet". It will even take care of things like <h2 class="foo">:
>
> #!/usr/bin/env ruby
> require ENV['TM_SUPPORT_PATH'] + "/lib/escape.rb"
> print e_sn(STDIN.read).sub(/^(\s*<)([^> ]*)( [^>]*)?>/,'\\1${1:\\2}\
> \3>').sub(/<\/([^>]*)(>\s*)$/, '</${1:\\1}\\2')
>
>
> Haris Skiadas
> Department of Mathematics and Computer Science
> Hanover College
>
>
>
>
>
> ______________________________________________________________________
> For new threads USE THIS: textmate at lists.macromates.com
> (threading gets destroyed and the universe will collapse if you don't)
> http://lists.macromates.com/mailman/listinfo/textmate
>
More information about the textmate
mailing list