On Feb 7, 2007, at 10:44 AM, Craig Francis wrote:
On 7 Feb 2007, at 16:09, Dr. Drang wrote:
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.
Thanks, but its sort of the inverse of what I need (the line stats the same in my date).
Sure, but the solution to an inverse problem often gives insight into the solution of the original problem. In this case, my command gets the length of the heading text and spits out that many hyphens; you need to get the length of the heading text (n) and spit out (50 - n) spaces. Not so different.
However, I wonder if this might help you...
# Open the Bundle Editor # Create a new Snippet (bottom left "+" drop down) # Set the "Edit Snippet" field to the text between the hyphens (don't include them)
$1 ${1/./=/g}
# Set the activation to "Tab Trigger" and the value to something like "h" # Clear the scope selector (unless you want to limit its usage)
Now, when you want to create a heading, you can type "h" in your document, press the [tab] key and type out the heading... the underline should be automatically created for you.
This is pretty neat. I don't remember seeing that substitution trick in the TM docs and will try to remember it. The snippet can't, however, adjust the length of the underline when I go back and change the heading text. This ability is a big deal to me because I'm always rewriting. (And since I've changed to using Atx-style headers, the best way to underline is moot for me now.)
-- Dr. Drang