TextMate bundle to insert a line of text above each line selected?
I'm looking for a way to insert a line of tex开发者_StackOverflow中文版t 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?
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.
I would record a macro:
- Insert a new line above with ⌥⌘↩
- Paste desired text
Then save it as a command and possibly assign a shortcut to it.
EDIT
The best way to achive what you want in TextMate is to select all the lines then hit ⌥⌘a (Text > Edit Each Line in Selection) then do all the keyboard mashing necessary to paste what you want where you want:
- ⌘← to go back to the beginning of the line
- ↩ to insert a newline, effectively adding a blank line above the current line
- ↑ to jump to the new blank line
- ⌘v to paste your text
It will do that on each selected line simultaneously.
You can save a few keystrokes the next time you have to do that by recording all these steps in a macro and save it as a command as in the first part of my answer.
To insert line above current line
I believe the key shortcut is: ⌥ + ⌘ + ↩
精彩评论