Politics, Programming and Possibilities
25 Apr
So here’s an idea I’ve been tossing around on the Textmate IRC channel and mailing list: What if Textmate supported multiple arbitrary simultaneous carets (MASC)? Allan Odgaard didn’t like the idea on first inspection, because it involves using the mouse–something that he is philosophically opposed to (for obvious reasons–it’s a text editor, after all). But I think there’d be many people who would receive this feature with eager arms and an appropriate amount of salivation.
So what is the idea? Here’s my original mailing list post:
What if you could add multiple carets to the current document by command-clicking? I imagine this to work in a way almost identical to that of the current snippet mechanism. For example: choose three caret locations, start typing, and in each location your text will show up. Press tab and the caret will focus in on the second of the two locations, highlighting the newly typed text (if any). Tab again and it moves to the third.
It would also be ideal to be able to highlight multiple selections in the same way–kind of like a powerful replace mechanism. Command-click and select three words in the document, then type one new word, and incrementally, all three words change to the new one.
Here is a screencast of MASC in action (Quicktime, 27 MB):
Update: The bundle is available as a disk image here. Key bindings and the “ß” marker character are subject to change. Use alt-s to mark and alt-f to convert markers to a snippet.
Update #2: No longer uses the beta marker. Uses special angle brackets instead.
Update #3: There is now a page for My Textmate Bundle that has updated information and a new (shorter) screencast.
11 Responses for "Textmate Snippets Like"
very nice!
I was actually fiddling with something similar, after reading your idea on the mailing list.
This is very smart, and exceptional good use of “Insert as snippet” feature.
Useful. Loving it.
Great stuff. What comes next?
[...] I’ve decided to put up a page for my personal Textmate Bundle for others to use. So far, it’s star (and only!) feature is the MASC work I’ve been doing. [...]
I couldn’t get it to work, so I made it work.
I put my changes into my SVN
http://textmate.svn.subtlegradient.com/Bundles/Duane%20Johnson.tmbundle/
It really freaking rocks! btw.
I like that each thing gets it’s own tab stop, too. Nicely done.
Very cool. It’s removing some things in some cases though. The ‘$’ character is problematic. Try this:
$aye
$bee
$cee
Then, mark each like so:
$<aye>
$<bee>
$<cee>
Upon hitting option f, I see:
$aye
aye
aye
If you do this:
<>$aye
<>$bee
<>$cee
It does this:
(blank line)
(blank line)
$cee
Also, since it’s insering a snippet, it winds up changing indentation in some cases.
Hi Brad–thanks for your diagnosis. I’ve fixed the $ issue (turns out I wasn’t escaping snippet-sensitive characters properly). As for the other issue, Allan Odgaard has mentioned that he will soon be providing an option to “insert as snippet” without the auto re-indenting.
Hmm, I’ve noticed that invoking Convert Snippet command re-indents line in certain languages (namely Pascal and Prolog, haven’t tried other yet). Setting ‘disableOutputAutoIndent’ in command’s .plist file doesn’t seem to help. Any ideas?
mbisha: Make sure you’re running the “cutting edge” version of Textmate, as Allan only recently made this feature available (TM revision #985). I made the same change as you specified and it works for me.
Probably I’ve incorrectly modified the command, as I’ve re-downloaded your bundle and it works great. Thank you.
can anyone tell me what a text mate does or lookes like??
Leave a reply