开发者

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

开发者 https://www.devze.com 2023-03-23 08:49 出处:网络
I\'m looking for a way to insert a line of tex开发者_StackOverflow中文版t above each line in the selected text in TextMate.

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:

  1. Insert a new line above with
  2. 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:

  1. to go back to the beginning of the line
  2. to insert a newline, effectively adding a blank line above the current line
  3. to jump to the new blank line
  4. 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: + +

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号