[TxMt] replace text at the end of a line

Allan Odgaard throw-away-1 at macromates.com
Tue Apr 3 03:02:26 UTC 2007


On 3. Apr 2007, at 03:27, Dan Lowe wrote:

> On Apr 2, 2007, at 8:02 PM, Raphael Villas wrote:
>> I'm using a regular expression to find groups of text that I need  
>> to replace. But instead of replacing the actual text that I have  
>> selected, I want to simply append some text to the end of the line  
>> that has been returned. For example, if I search in the project,  
>> retrieving ten different lines of code, how to do I insert a  
>> specific string of text (e.g. "Put this text at the end of the  
>> line") at the end of each of those lines?
>>
>> Is there a way to do this?
>
> Yes. Match the entire line, memorize it, and replace it with itself  
> plus appended text.
>
> Find: ^(.*foo.*)$
> Replace: $1 Put this text at the end of the line

$0 refers to the full match, so it is not necessary to make an  
explicit capture.




More information about the textmate mailing list