[TxMt] Command or Macro help

Allan Odgaard allan at macromates.com
Wed Mar 9 16:48:20 UTC 2005


On Mar 9, 2005, at 17:16, Ketan Anjaria wrote:

> Not sure if this needs to be a command or macro or what but I can't 
> seem to figure this out.

Making it a command makes it possible to change it later, but since a 
command needs to work on the selection or entire buffer, you'd have to 
select e.g. the first line of your function first, or have a macro do 
that, and run the command.

A macro OTOH requires no real knowledge of programming, although in 
this case probably does require regular expression knowledge. I did 
your stuff as a macro, I don't know how much of your function example 
is variable -- I made it take a variable number of parameters.

The outline of the macro is:
   1) search backwards for {
   2) select the entire line
   3) duplicate the selection (on a new line)
   4) make the changes to the copy (using a regex to change the 
parameter stuff, so that a variable number of parameters are supported)

Step 4 is what you may instead want to do as a command, so that you can 
make changes and/or use a real language, if doing the necessary steps 
in recording mode gets to complex.

I attached my macro, I made it ctrl-shift-T since cmd-T is the file 
chooser! :)

Also, I actually made a step 0 which is “move to end of line”, that 
way, the macro works even when you're in front of the { on the first 
line.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: AS Trace.tmbundle.zip
Type: application/zip
Size: 1681 bytes
Desc: not available
URL: <http://lists.macromates.com/textmate/attachments/20050309/167f4624/attachment.zip>


More information about the textmate mailing list