Search code examples
linuxstringtexttextmatetextmatebundles

TextMate bundle to insert a line of text above each line selected?


I'm looking for a way to insert a line of text above each line in the selected text in TextMate.

Does anyone know how to write a command or snippet to do this?

Example, selected text:

This is line 1
This is line 2
This is line 3
This is line 4

I want to insert the following above each line selected:

--im an inserted line--

Which would result in the following:

-

-im an inserted line--
This is line 1
--im an inserted line--
This is line 2
--im an inserted line--
This is line 3
--im an inserted line--
This is line 4

Could this be done using *NIX commands then I could setup a TextMate command to do this?


Solution

  • Select your text, press APPLE + F, then replace \n with \n--Im an inserted line--\n. Make sure that 'Regular expression' is ticked and that you hold in SHIFT while pressing the 'Replace All' button.