In CSS, I block out parts of the code with comments like...
/*--------------------------------------------------*/ /* Heading */
I am a little obsessive compulsive, in that each of the comments should use 50 hyphens to keep them all neat and tidy... in a mono- type font.
Is it possible to make a snippet that will add the relevant number of spaces after the words?
So in the example above, the word "Heading" uses 7 characters, plus 1 for the space on the left, leaves 42 spaces on the right.
I was considering the use of...
/*--------------------------------------------------*/ /* $1 ${1/./\0x0D/g} */$0
Where the "\0x0D" is the hex code for the back space key.
Any ideas?
This message contains information which may be confidential and privileged.Unless you are the intended recipient (or authorized to receive this message for the intended recipient), you may not use, copy, disseminate or disclose to anyone the message or any information contained in the message. If you have received the message in error, please advise the sender by reply e-mail, and delete the message. Thank you very much. (A)
This message contains information which may be confidential and privileged.Unless you are the intended recipient (or authorized to receive this message for the intended recipient), you may not use, copy, disseminate or disclose to anyone the message or any information contained in the message. If you have received the message in error, please advise the sender by reply e-mail, and delete the message. Thank you very much.
*Please* don't post this rubbish. Mails to the TextMate list are archieved online, so if it contains confidential stuff you've got a problem anyways. Additionally to being not useful, it's annoying as well.
About your problem: You can write a command (not a snippet) that gets the length of the current and the previous line and appends the right amount of spaces and '*/' to the current line.
The best solution, of course, is not to be obsessive compulsive ;-) Keeping the spaces aligned when you're editing comments is a maintenance annoyance. If you want boxes, I suggest using
/******************* * text *****************/.
HTH, Nico
Thanks Nico,
Unfortunately I cannot remove that copyright rubbish... its forced on by the mail server.
As to the comments though, I have been using this style for about 5 years now, and I don't really want to change it, mostly because I use it for as an anchor when navigating the CSS - and its good for checking when someone else has been editing my files.
I would be great if there was a solution, but if not, thanks anyway Nico.
Craig
On 7 Feb 2007, at 13:18, Nicolas Weber wrote:
This message contains information which may be confidential and privileged.Unless you are the intended recipient (or authorized to receive this message for the intended recipient), you may not use, copy, disseminate or disclose to anyone the message or any information contained in the message. If you have received the message in error, please advise the sender by reply e-mail, and delete the message. Thank you very much.
*Please* don't post this rubbish. Mails to the TextMate list are archieved online, so if it contains confidential stuff you've got a problem anyways. Additionally to being not useful, it's annoying as well.
About your problem: You can write a command (not a snippet) that gets the length of the current and the previous line and appends the right amount of spaces and '*/' to the current line.
The best solution, of course, is not to be obsessive compulsive ;-) Keeping the spaces aligned when you're editing comments is a maintenance annoyance. If you want boxes, I suggest using
/*******************
- text
*****************/.
HTH, Nico
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
This message contains information which may be confidential and privileged.Unless you are the intended recipient (or authorized to receive this message for the intended recipient), you may not use, copy, disseminate or disclose to anyone the message or any information contained in the message. If you have received the message in error, please advise the sender by reply e-mail, and delete the message. Thank you very much. (A)
On 7 Feb 2007, at 13:38, James Edward Gray II wrote:
On Feb 7, 2007, at 7:27 AM, Craig Francis wrote:
Unfortunately I cannot remove that copyright rubbish... its forced on by the mail server.
Nonsense. You can move your list membership to a free email account with a web interface, Gmail for example.
Going slightly off-topic... but company policy (can get fired if I don't follow it) is that we have to use our email systems.
Me thinks they are "logging" our emails, and web access (big brother)... the latter of which has been confirmed (after a little bit of packet sniffing).
This message contains information which may be confidential and privileged.Unless you are the intended recipient (or authorized to receive this message for the intended recipient), you may not use, copy, disseminate or disclose to anyone the message or any information contained in the message. If you have received the message in error, please advise the sender by reply e-mail, and delete the message. Thank you very much. (A)
On Feb 7, 2007, at 8:43 AM, Craig Francis wrote:
On 7 Feb 2007, at 13:38, James Edward Gray II wrote:
On Feb 7, 2007, at 7:27 AM, Craig Francis wrote:
Unfortunately I cannot remove that copyright rubbish... its forced on by the mail server.
Nonsense. You can move your list membership to a free email account with a web interface, Gmail for example.
Going slightly off-topic... but company policy (can get fired if I don't follow it) is that we have to use our email systems.
Me thinks they are "logging" our emails, and web access (big brother)... the latter of which has been confirmed (after a little bit of packet sniffing).
Been there. I totally feel your pain. That little notice doesn't bother me a bit. You could add your own signature in your email app too. Something like:
"Please disregard the following message, I have no control over it" thomas Aylott — design42 — subtleGradient — CrazyEgg
On 7 Feb 2007, at 14:31, subtleGradient / Thomas Aylott wrote:
On Feb 7, 2007, at 8:43 AM, Craig Francis wrote:
On 7 Feb 2007, at 13:38, James Edward Gray II wrote:
On Feb 7, 2007, at 7:27 AM, Craig Francis wrote:
Unfortunately I cannot remove that copyright rubbish... its forced on by the mail server.
Nonsense. You can move your list membership to a free email account with a web interface, Gmail for example.
Going slightly off-topic... but company policy (can get fired if I don't follow it) is that we have to use our email systems.
Me thinks they are "logging" our emails, and web access (big brother)... the latter of which has been confirmed (after a little bit of packet sniffing).
Been there. I totally feel your pain. That little notice doesn't bother me a bit. You could add your own signature in your email app too. Something like:
"Please disregard the following message, I have no control over it" thomas Aylott — design42 — subtleGradient — CrazyEgg
Now that's a good idea... will check over the company rule book tonight, as even though its big enough to cause a desk to collapse, I doubt they have thought of that.
:-D
This message contains information which may be confidential and privileged.Unless you are the intended recipient (or authorized to receive this message for the intended recipient), you may not use, copy, disseminate or disclose to anyone the message or any information contained in the message. If you have received the message in error, please advise the sender by reply e-mail, and delete the message. Thank you very much. (A)
On Feb 7, 2007, at 8:27 AM, Craig Francis wrote:
Thanks Nico,
Unfortunately I cannot remove that copyright rubbish... its forced on by the mail server.
As to the comments though, I have been using this style for about 5 years now, and I don't really want to change it, mostly because I use it for as an anchor when navigating the CSS - and its good for checking when someone else has been editing my files.
I would be great if there was a solution, but if not, thanks anyway Nico.
In TextMate there is almost always a solution, but occasionally you have to alter the question slightly ;)
It would definitely be easy to write a TextMate command utilizing a ruby script or whatnot, that goes through the entire file and adjusts things like that. So you would have to invoke the command whenever you want things fixed. It would take as input the "selection or document", and output to replace selected text (or we can even use insert as snippet if you want the caret position preserved). Would something like that that be helpful for your problem?
Craig
Haris
On 7 Feb 2007, at 14:19, Charilaos Skiadas wrote:
It would definitely be easy to write a TextMate command utilizing a ruby script or whatnot, that goes through the entire file and adjusts things like that. So you would have to invoke the command whenever you want things fixed. It would take as input the "selection or document", and output to replace selected text (or we can even use insert as snippet if you want the caret position preserved). Would something like that that be helpful for your problem?
To be fair, its not a major problem... holding down the [delete] key works fine - been using that for years.
However, it would be nice to have a string of 50 spaces (between the comment marks), then as you type, it replaces them, keeping the character count to 50... if it could be done, then it opens a few more possible snippets I would like to try.
One alternative is to just remember to flip into "Edit > Mode > Overwrite Mode".
Thanks for the replies so far... and sorry about the stuff which will follow this.
Craig
----------------------
This message contains information which may be confidential and privileged.Unless you are the intended recipient (or authorized to receive this message for the intended recipient), you may not use, copy, disseminate or disclose to anyone the message or any information contained in the message. If you have received the message in error, please advise the sender by reply e-mail, and delete the message. Thank you very much. (A)
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
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).
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 message contains information which may be confidential and privileged.Unless you are the intended recipient (or authorized to receive this message for the intended recipient), you may not use, copy, disseminate or disclose to anyone the message or any information contained in the message. If you have received the message in error, please advise the sender by reply e-mail, and delete the message. Thank you very much. (A)
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