I'm trying to learn about writing useful snippets for things I do often. It looks like I need some conceptual help. For example, I use this snippet:
<tr> <td><cite>${1:title}</cite></td> <td>${2:composer}<br /> arr:${3:arranger}</td> </tr> </table>$0
with a tab trigger of </table>
already helps a lot when building tables of works performed. It nicely gets rid of the ending </table> and inserts another set when I press tab at the end of the snippet.
That worked so well I got greedy. I'd like to cause the snippet to force the title be Title Case.
A second interest is an easy way to get rid of the break and the arranger when the piece doesn't have one without killing the ability to use a tab trigger at the end. I can use lots of deletes. Is there a better way.
Fascinating tool, TextMate.
Lewy
PS: I'm having trouble getting posts into the list. If this is a duplicate, please forgive me.
Hi Lewis,
you don't need to post three times we all got it the first time but maybe nobody had time to answer.
Lewis Overton schrieb:
I'm trying to learn about writing useful snippets for things I do often. It looks like I need some conceptual help. For example, I use this snippet:
<tr> <td><cite>${1:title}</cite></td> <td>${2:composer}<br /> arr:${3:arranger}</td> </tr> </table>$0
with a tab trigger of </table>
already helps a lot when building tables of works performed. It nicely gets rid of the ending </table> and inserts another set when I press tab at the end of the snippet.
That worked so well I got greedy. I'd like to cause the snippet to force the title be Title Case.
Pardon?
A second interest is an easy way to get rid of the break and the arranger when the piece doesn't have one without killing the ability to use a tab trigger at the end. I can use lots of deletes. Is there a better way.
you can put the br and arranger inside another $ e.g.
<tr> <td><cite>${1:title}</cite></td> <td>${2:composer}${4:<br /> arr:${3:arranger}}</td> </tr> </table>$0
Now you can tab through: title - composer - arranger and with the next tab you'll select the whole br+arranger block and can delete it.
Fascinating tool, TextMate.
Lewy
PS: I'm having trouble getting posts into the list. If this is a duplicate, please forgive me.
Max
Hey Lewis,
On 12/3/06, Lewis Overton akakie@gmail.com wrote:
I'm trying to learn about writing useful snippets for things I do often. It looks like I need some conceptual help. For example, I use this snippet:
<tr> <td><cite>${1:title}</cite></td> <td>${2:composer}<br /> arr:${3:arranger}</td> </tr> </table>$0
with a tab trigger of </table>
That worked so well I got greedy. I'd like to cause the snippet to force the title be Title Case.
Can't you just type it out in title case? Or you could use a class attribute on the td or cite tag and use CSS to style it with the text-transform property like this:
HTML code: <td class="title"><cite>song title</cite></td>
CSS code: td.title { text-transform: capitalize; }
that would display the text to the browser like this: Song Title
Otherwise if the text is getting pasted in or something you could do a transformation on it, see: http://macromates.com/textmate/manual/snippets#transformations
Hope that helps!
-Brian
First, apologies for multiple posts. I'm not seeing my own posts, despite mailman preferences.
The best answer is to type the title correctly, since Title Case is not just capitalizing every word. It is actually complex. Rules from Gregg include:
(360) Capitalize all words with four or more letters. Also, capitalize all words with fewer than four letters, except articles, short conjunctions and short prepositions.
(361) (a) Capitalize the first and last word of a title; (b) capitalize the first word following a dash or colon; (c) capitalize short words in titles that serve as adverbs rather than prepositions; (d) capitalize short prepositions when used with prepositions of four-or-more letters (such as "Sailing Up and Down the St. Lawrence"); (e) do not capitalize word-wraped words.
There are other rules and gobs of exceptions. Algorithms can get close, however. Textmate has Text -> Convert -> to title case which does fairly well. I had hoped to find a way to use that function, since a program to get close is 10-15 lines of code.
I also wanted to learn how to use transforms, since I found the write up in the manual kind of obscure.
Thanks for your patience. Lewy
On 12/3/06, Brian Landau brianjlandau@gmail.com wrote:
Hey Lewis,
On 12/3/06, Lewis Overton akakie@gmail.com wrote:
I'm trying to learn about writing useful snippets for things I do often.
It
looks like I need some conceptual help. For example, I use this snippet:
<tr> <td><cite>${1:title}</cite></td> <td>${2:composer}<br /> arr:${3:arranger}</td> </tr> </table>$0
with a tab trigger of </table>
That worked so well I got greedy. I'd like to cause the snippet to force
the
title be Title Case.
Can't you just type it out in title case? Or you could use a class attribute on the td or cite tag and use CSS to style it with the text-transform property like this:
HTML code:
<td class="title"><cite>song title</cite></td>
CSS code: td.title { text-transform: capitalize; }
that would display the text to the browser like this: Song Title
Otherwise if the text is getting pasted in or something you could do a transformation on it, see: http://macromates.com/textmate/manual/snippets#transformations
Hope that helps!
-Brian
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate