[TxMt] Odd behavior with "Move Selection Line Up" and "Line Down"
Michael Henry
macromates at drmikehenry.com
Mon May 22 02:18:57 UTC 2006
Paul McCann wrote:
> While not ideal, one way to get a partial solution to this is to
> override the "Line Up" and "Line Down" commands using macros.
>
> Sselect "Automation => Start Macro Recording" then
>
> (1) Select "Text => Move Selection => Line Up"
> (2) Hit your up arrow
>
> and finally select "Automation => Stop Macro Recording". Then use
> "Automation => Save Scratch Macro..." to save this as, say, "upline"
> with a blank scope and the same key command as "Text => Move Selection
> => Line Up". Repeat with obvious modifications for "downline".
Thanks for the suggestion. I agree that it's a big improvement for the
typical use case (moving just a single line), and I may end up with this
very work-around until the fix is made in TextMate itself. Before
posting, I'd created my own bundle and tried making a command that
behaved the way I'd like, but I didn't know enough to get all the
behavior correct.
Before purchasing TextMate (and the Macbook Pro to run it on :-)) I'd
seen Duane Johnson's MASC hack for simultaneous caret manipulation (see
http://blog.inquirylabs.com/my-textmate-bundle/), done solely with an
end-user-supplied bundle. The MASC code is a good hack, and it makes
for a nice advertisement for the power of TextMate's extensibility. But
I didn't look at the actual MASC code before I delved into the bundle
editor to hack out my own "move line up" functionality. I started
making a command, but I got stalled at the point where I wanted my
command to move the caret.
I then studied the MASC bundle to see how he worked his magic. It seems
that Duane used snippets to position the caret. He grabs a subset of
the buffer, converts it to a snippet, puts in tab-stops (which give the
caret positioning he needs), and inserts the snippet into the buffer,
replacing the original contents. This is a neat hack, and I may well
use it in my attempt to make a complete temporary fix for "move line up".
But I do wonder if there is some other way to position the cursor in the
buffer, short of inserting a snippet. Does anyone have a better
suggestion for bundle authors who need to process the current buffer and
move the caret as a result? Or is the snippet hack the best technique
at this time? I'm on a quest to learn how to tailor TextMate, and this
seems like a capability I'm going to need in general.
Thanks,
Michael Henry
More information about the textmate
mailing list