[TxMt] Snippet Overtype

Dr. Drang drdrang at gmail.com
Wed Feb 7 16:09:26 UTC 2007


On Feb 7, 2007, at 7:02 AM, Craig Francis wrote:

> In CSS, I block out parts of the code with comments like...
>
>
> /*--------------------------------------------------*/
> /* Heading                                          */
>
> [snip]
>
> Any ideas?

It sounds similar to something I did last year to handle Setext-style  
headings in my Markdown documents. A Setext-style heading looks like  
this:

Heading
-------

or this:

Heading
=======

What I wrote was a TextMate macro/command combination that figured  
out how long the text was and added the same number of hyphens or  
equals under it. Lengthening or shortening the text and invoking the  
macro would lengthen or shorten the underline, as needed. It strikes  
me that this could be altered to do what you want. There's a complete  
writeup in my blog at

<http://www.leancrew.com/all-this/2006/05/ 
markdown_headings_in_textmate.html>



Alternately, you could just make a snippet that looks like

> *--------------------------------------------------*/
> /* $1                                                 */

and go into overwrite mode (Edit->Mode->Overwrite Mode or Command- 
Option-O) so your heading text eats the spaces as you type. This is  
certainly simpler to write but requires a few more keystrokes to use,  
and you have to remember to go into and out of overwrite mode.

--
Dr. Drang






More information about the textmate mailing list