TextMate Tricks

Time for another round of links to cool stuff related to TextMate.

Multiple Arbitrary Simultaneous Carets

Duane Johnson, who should already be known for his many Rails bundle contributions (which started as syncPeople on Rails) has taken it upon himself to implement requests that I turn down. His wish? To have multiple arbitrary simultaneous carets, so that he could type once, and have the text inserted multiple places.

It sounds like something only direct access to the text editing core would allow, but not if you are creative. Witness his MASC bundle (well, it’s actually his TextMate bundle, but he refers to this part of it as MASC). There is a screencast which shows it in action, and it looks very smooth!

WebMate — Editable HTML Preview

James G. Speth had another itch to scratch (actually two, but only one can be downloaded from his website). The ability to make the web preview of TextMate editable, so while you can currently edit the HTML source and preview that, you can’t edit the preview, and have the source updated accordingly. Well, say hello to WebMate, a plug-in which allows just that!

Edit in TextMate from Apple Mail

Hawk Wings notes that TextMate can be used as external editor for Mail. Although I myself am behind this feature, I haven’t made any mention of it outside of the release notes, but it is actually quite nice.

As noted on the blog, you need to install the Edit in TextMate input manager, which is done by clicking the gear menu in the status bar (inside TextMate), navigating to the TextMate submenu and selecting Install “Edit in TextMate”…

After that, relaunch Mail, and it will have a new item in the Edit menu, which allows you to call up TextMate for the current letter (in the compose window). If you are using the cutting edge version of TextMate (presently r985) or have the Mail bundle from the subversion repository, you will get syntax highlighting of quoted text, and ⌃Q will be overloaded to reformat text respecting quotation levels, plus a few other niceties, e.g. ⌃{ inserts [...].

Note: This only works in Tiger. Also note that this is essentially a hack, and I of course make no claim to its suitability for any purpose etc. The source for the hack (input manager) is available from the bundles repository.

PyTestMate — Supporting py.test

Timothy Grant has added support for py.test in the form of PyTestMate.

Trick Your TextMate: Snippets

Garrett Domon has put up part two of his Trick Your TextMate series.

PHPfi Lookups in TextMate

Bob McDonald describes how to make PHPfi lookups from TextMate. This allows access to the PHP documentation even when offline, as the default Documentation for Word in the PHP bundle uses the online site for PHP. This of course requires that you have PHPfi installed.

19 Comments

  1. 28 Apr 2006 | # Peter wrote…

    I don't get syntax highlightling for quoted text using the mail bundle. I have the latest version and all other bundle feature seem to work correctly.

    It's a great hack, I've been hoping for one for a while. Should save me a lot of time responding to similar emails, using some snippits.

  2. 28 Apr 2006 | # Allan Odgaard wrote…

    Peter: Is the language set to Mail?

    Does your quoted text look like normal quoted text, that is: > > double quoted text > single quoted text

    If it does, and the language is Mail, what shows in the tool tip if you press ctrl-shift P on one of the quoted lines?

  3. 28 Apr 2006 | # Peter wrote…

    Allan,

    The language is set to Mail, and the guoted text looks as you described.

    I get the following tool tips whne pressing ctrl-shift-p:

    When using 'edit-in-textmate' with gmail both single and double quoted lines give the following:

    text.plain.mail meta.paragraph.text

    Using it in mail single quoted lines:

    text.plain.mail markup.quote.mail.single

    Double quoted:

    text.plain.mail markup.quote.mail markup.quote.mail.double

    in all cases there is no highlighting, I tried different themes as well to make sure it wasn't just my eyes.

  4. 28 Apr 2006 | # Allan Odgaard wrote…

    Ah, come to think of it, I actually do not think any of the themes address the quoted text scopes, except MagicWB.

    You can go to Preferences -> Fonts & Colors and add a style for markup.quote to color the text. If you want different quotation levels to have different colors, you can make multiple entries (a catch all for markup.quote, and then a new style for markup.quote.double, etc. Use ctrl-shift P to find the names).

    As fro GMail, it sounds like the grammar doesn’t parse GMail’s quoting style. I will check that out later and update the grammar accordingly.

  5. 28 Apr 2006 | # Peter wrote…

    Allen,

    Worked perfectly, thanks! I personally don't care about Gmail compatability. I was just seeing if it would work.

  6. 04 May 2006 | # UltraBob wrote…

    Hey thanks for the mention. I just wish my contribution was even half as cool as the others. ;)

  7. 16 May 2006 | # Quentin Stafford-Fraser wrote…

    "Edit in TextMate" is fabulous.

    I write my blog using WordPress, which I love, but whenever a post gets long enough that I don't want to keep typing into a browser window, I just hit Ctrl-Cmd-E and get all the cool HTML features.

    Very nice – thanks. Oh, and I did this post the same way :-)

  8. 01 Mar 2007 | # ole wrote…

    When I use file encoding ISO-8859-1 and write "æ", "ø" or "å", Safari stops responding when I save in TextMate.. Why? I got it to work with UTF8.

  9. 01 Mar 2007 | # Allan Odgaard wrote…

    ole: Could you be more specific? E.g. provide steps to reproduce.

  10. 08 May 2007 | # Bernhard wrote…

    Just a note: The "Edit in Textmate" InputManager does prevent using the keyboard command Apple-C to copy text from a Skype chat history list. Disable the InputManager just for Skype by typing "defaults write -app Skype DisableEditInTextMateMenuItem 1" in a Terminal window to make Command-C working again.

  11. 17 Jul 2007 | # kmf wrote…

    This is totally awesome! Thanks

  12. 22 Nov 2007 | # Jami Haavisto wrote…

    Thank you Bernhard ! It's been driving me nuts not been able to copy with Apple-C in Skype..

    Btw. The link for WebMate doesn't work anymore. The link to the zip is: http://end.com/~speth/WebMate.zip. (Taken from http://wiki.macromates.com/Main/Plugins)

  13. 14 Apr 2008 | # Dave Everitt wrote…

    that WebMate link is dead…

  14. 28 Jan 2009 | # john p. wrote…

    My use of texmate is blossoming. However, I find that edit in textmate, which is so important, fails to engage spelling when editing text in a blog comment form (from safari)m although spelling works in the actual textarea in safari. Larger comments replies in small windows are better edited in textmate of course.

    Is this case of no spell check in temporary docs true for you, or a known limitation generally?

  15. 28 Jan 2009 | # Allan Odgaard wrote…

    john: You can toggle “Check Spelling as You Type” from the Edit → Spelling menu.

  16. 28 Jan 2009 | # john p. wrote…

    Allan: Yes sure, I am familiar with that. It didn't work in a temporary file, under the circumstances. I shall have to test again, though, I am fairly certain there were corrections to be made; but the TXM templates colouring may have obfuscated the signs. And yet, I am sure I called up the suggestion box. Oh well…let's hear from others. I'm for a spell of sleep now.

  17. 02 Feb 2009 | # Allan Odgaard wrote…

    john: For source code, it will only spell check string literals, so it might be, that you have the language set wrong. Look in the status bar and switch it to Markdown (or plain text).

  18. 27 Apr 2009 | # Matthew J McNeil wrote…

    any possibility of also checking spelling in source code comments?

  19. 27 Apr 2009 | # Allan Odgaard wrote…

    Matthew: See this mailing list post.

Comments closed, you can use the mailing list for discussion.