In TextMate, open the Bundle Editor and select the language you'd like to do this in. (If you'd like to have this functionality in all languages, use the Source bundle) Click the plus symbol at the bottom left, and choose "New Command." Chose "Nothing" for the Save field and "Selected Text or Line" for the two input fields. Then paste this into the Commands field:
#!/usr/bin/python
import sys
commandLine = raw_input("")
tmArgs = commandLine.split()
numberOfArgs = len(tmArgs)
for i in range(eval(tmArgs[0])):
for j in range(1, numberOfArgs):
sys.stdout.write(tmArgs[j])
You can then choose a keyboard shortcut to activate this with in the Activation field. The way it works is very similar to that emacs command: type the number of characters you want followed by the character. Then select both of them (this step is unnecessary if they're the only text on the line) and press the shortcut key. My script allows you to specify multiple characters to print, delimited by spaces. So if you typed
10 - =
and hit the shortcut key, you'd get
-=-=-=-=-=-=-=-=-=-=
Edit: After thinking about it...here's another version. This one will print the string after the number. So for example
6 -= (space)
prints
-= -= -= -= -= -=
Here's that version:
#!/usr/bin/python
import sys
import string
commandLine = raw_input("")
timesToPrint = eval(commandLine.split()[0])
firstSpace = string.find(commandLine, " ")
for i in range(timesToPrint):
sys.stdout.write(commandLine[firstSpace + 1:])