[TxMt] replace text at the end of a line

Dan Lowe dan at tangledhelix.com
Tue Apr 3 01:27:11 UTC 2007

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

Obviously you can use a more complex regex; in this case I was  
searching for "foo".


More information about the textmate mailing list