[TxMt] Re: get last 3 words

Hans-Joerg Bibiko bibiko at eva.mpg.de
Wed Jun 20 07:50:55 UTC 2007


On 19 Jun 2007, at 22:11, Christoph Koehler wrote:
>>  Well, there're some possibilities to do that.
>>  First in my mind would be if the number of words is fixed, in your
>> example three, to record a macro:
>>
>>  moveWordRight
>>  moveWordLeftAndModifySelection
>>  moveWordLeftAndModifySelection
>>  moveWordLeftAndModifySelection
>>
>>
> Yeah that works, but that's not the whole story :) I need to get the
> last 3 words and then evaluate them based on what they are. Is that
> possible after selecting them with a macro? Sorry for the newbie
> questions!
>

-Write a command MYCOMMAND which evaluate something with  
$TM_SELECTED_TEXT (it contains the last three words)
-Record a macro which does the following:

moveWordRight
moveWordLeftAndModifySelection
moveWordLeftAndModifySelection
moveWordLeftAndModifySelection
MYCOMMAND

and save it.
Please note, if you change MYCOMMAND the macro won't notice your  
changes because the entire code is saved within this macro. You have  
to rerecord your macro.

If you are not lucky by using a macro you can write a command using  
Ruby, Perl, or what ever and work on $TM_CURRENT_LINE (if the three  
last words are in the same line) or on the entire document (if not).

Hans



More information about the textmate mailing list