[TxMt] Re: Textmate: How do I enter a repeated sequence of characters?
Guido Governatori
gvdgdo at gmail.com
Sat Feb 7 02:24:58 UTC 2009
On 07/02/2009, at 11:24 AM, Debajit wrote:
>
> I often need to enter text (consisting of repeated characters) like
> this:
>
> ------------------------------------
> TODO
> ------------------------------------
>
> In emacs, I can do a
>
> C-u 60 -
> that's a Ctrl+U followed by a "60" followed by a "-", which makes
> entering a
> repeated sequence of characters easy.
>
> Is there any way to do something like this in TextMate?
A simple solution is to create a new command
#!/usr/bin/env ruby -wKU
linea = ENV['TM_CURRENT_LINE']
linea = linea.split(" ")
character = linea.pop
number = linea.pop.to_i
print linea.join(" ") + " "
number.times {print character}
# end
with
Input: selected text or line
Output: insert as snippet
Activation, Key Equivalent: C-u
then to us the command type
10 *
and then C-u to have 10 * replaced by *********
It is possible to use stings of text, e.g., 5 +* prints +*+*+*+*+*+*
You have to leave an empty space before the numerical value and an
empty space between the two arguments. (In the current form, all
repeated empty spaces are collapsed to 1). An alternative is to use a
macro to select the two arguments and then use the main idea of the
script above.
All the best
Guido
--
Guido Governatori
http://www.governatori.net/Textmate
More information about the textmate
mailing list