3

In Emacs, I can easily select a phrase in the middle of a sentence using incremental search. For example, I've written the sentence "I have never been to Paris, but I have taken a virtual tour of the Eiffel Tower, and I'm very excited to see it in person". Then I decide that I'd rather move "I have taken a virtual tour of the Eiffel Tower" to the beginning of the sentence.

To do this in Emacs, I would use incremental search to find "I", move to the start of the word, set the mark, then search again for "Tower" and move to its end. Now everything in between is a selected region and can be operated on.

Can I achieve the same result in Textmate?

I am familiar with its incremental search, but I cannot find a connection to selecting text. There is the "Extend selection to include next" command in the Text Bundle (bound to ^W), but that doesn't work for two different search targets and makes multiple selections rather than selecting everything in between.

Extending the selection using ⇧⌥ and arrow keys is the closest I've come up with, but it means tapping an arrow key for every word. Selecting to the end or beginning of a line is not what I want; I'm looking to capture something in the middle of the line.

I'm not tied to using incremental search: it's just how I do this in Emacs. (Is there some way to use ⌥^B in non-source-code text?) I'm open to any solution that allows me to quickly move from one arbitrary place in the text to another, selecting everything in between, without switching to the mouse.

1

Cocoa/OS X's built-in Key Bindings system make this possible. The text view in TextMate implements the highly-relevant NSResponder action methods setMark: and selectToMark:.

The TextMate manual explains that ~/Library/Application Support/TextMate is the right place for a custom KeyBindings.dict file to set the bindings for those actions. Adding these lines to the dictionary:

"^ "       = "setMark:";
"^~ "      = "selectToMark:";

binds ⌃-Space to set the mark (the same binding for this action as Emacs) wherever the cursor is currently located, and ⌃-⌥-Space to select from the cursor to the previously-set mark. This is one extra keypress compared to Emacs, but it'll get the job done.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .