Hello, I found a .tmMacro file someone put up, it will allow me to remove trailing spaces and tabs on save. Works nice, for one flaw.
If I have any text selected, that selected text is replaces with what seems to be the contents of the entire file.
I can not figure out how to even edit the .tmMacto once installed. I can put the cursor in the bundle editor area, but it will not allow any chances.
I can not open the .tmMacro file in TM, so I could use the shell, but that seems strange, and it is a plist, and not entirely sure what to edit.
The Macro has two commands executeCommandWithOptions { beforeRunningCommand = nop; command = "perl -pe 's/[\t ]+$//g'"; input = document; output = replaceSelectedText; }
executeCommandWithOptions { beforeRunningCommand = saveActiveFile; input = none; output = discard; }
* I can sort of hack this out on my own by making a empty command, then recording a macro to and hooking those two together. The above seems cleaner though.
Any ideas what I should edit? The perl seems fine, a direct copy from the TM built in to remove spaces and tabs, maybe the output = replaceSelectedText; needs changing? -- Scott * If you contact me off list replace talklists@ with scott@ *
On 02.04.2009, at 07:57, Scott Haneda wrote:
I can not open the .tmMacro file in TM, so I could use the shell, but that seems strange, and it is a plist, and not entirely sure what to edit.
You can edit such file. Simply open the Bundle Editor, hold the key ⌥ while drag&drop the macro to the TextMate dock item. Or open the macro in the Finder and open that file with tm* with TM while holding the ⌥ key.
The Macro has two commands executeCommandWithOptions { beforeRunningCommand = nop; command = "perl -pe 's/[\t ]+$//g'"; input = document; output = replaceSelectedText; }
What happens if you replace "document" by "selection" ?
After editing such a tm* file you have to Flush Cache & Reload Bundles (Bundles > Bundle Editor > press ⌥ > Flush...) or simply restart TM.
--Hans
Thanks for your other tips, see comments below...
On Apr 2, 2009, at 12:29 AM, Hans-Jörg Bibiko wrote:
The Macro has two commands executeCommandWithOptions { beforeRunningCommand = nop; command = "perl -pe 's/[\t ]+$//g'"; input = document; output = replaceSelectedText; }
What happens if you replace "document" by "selection" ?
I solve the issue of the selection getting replaced by something, but the stripping of tabs and spaces no longer works.
After editing such a tm* file you have to Flush Cache & Reload Bundles (Bundles > Bundle Editor > press ⌥ > Flush...) or simply restart TM.
Thanks -- Scott * If you contact me off list replace talklists@ with scott@ *
Le 2 avr. 09 à 10:00, Scott Haneda a écrit :
Thanks for your other tips, see comments below...
On Apr 2, 2009, at 12:29 AM, Hans-Jörg Bibiko wrote:
The Macro has two commands executeCommandWithOptions { beforeRunningCommand = nop; command = "perl -pe 's/[\t ]+$//g'"; input = document; output = replaceSelectedText; }
What happens if you replace "document" by "selection" ?
I solve the issue of the selection getting replaced by something, but the stripping of tabs and spaces no longer works.
Couldn't you discard the output as what can be done for the commands?
Try: output = discard;
Best regards, Mathieu
___________________________________________
Mathieu Godart
Skype: mathieu_godart MSN: mathieu_godart@hotmail.com
ASIC Integration Manager Coolsand Technologies ___________________________________________
On 02.04.2009, at 11:34, Mathieu Godart wrote:
Couldn't you discard the output as what can be done for the commands?
Try: output = discard;
No. I guess the problem is the Perl stuff. What do you see in the Bundle Editor if you select your macro in question and click on executeCommandWithOption?
command = "perl -pe 's/[\t ]+$//g'";
or
command = "perl -pe 's/[\\t ]+$//g'";
?
On the other hand you can simply write two tiny tmCommands, one for the Perl stuff and one for saving it, and record a that macro again.
--Hans
There is a downside to this, there is screen blink and redraw issues as a result of the time it takes a macro to run I suspect. Attaching to to cmd-S is probably not the best idea. I attach it to another command cmd-shift-? since that seems to give TM a hard time anyway.
Using this set of steps all the time seems to get TM in a bad mood over time.
On Apr 2, 2009, at 3:09 AM, Hans-Jörg Bibiko wrote:
On the other hand you can simply write two tiny tmCommands, one for the Perl stuff and one for saving it, and record a that macro again.
-- Scott * If you contact me off list replace talklists@ with scott@ *
I wonder if y'all know that there's a standard action for stripping trailing whitespace in the text bundle, which is bound to shft-cmd-bkspace.
Of course, that is the action I am binding to in step two of the command I made. It is just if you hook it to command-S, there is some flicker and screen redraw issues at times.
There are several things that leave artifacts on screen in TM that I have run into. Closing the file and opening it again always solves it.
On Apr 3, 2009, at 3:48 PM, Rick DeNatale wrote:
I wonder if y'all know that there's a standard action for stripping trailing whitespace in the text bundle, which is bound to shft-cmd- bkspace.
-- Scott * If you contact me off list replace talklists@ with scott@ *