Hello all,
I'm looking for a way to delete all extra space from a file on save. Extra space would include extra space on the end of lines. For empty lines, this would delete all space contained within them. Any ideas?
Thanks,
Michael
On Sep 10, 2007, at 11:51 AM, Michael Jackson wrote:
I'm looking for a way to delete all extra space from a file on save. Extra space would include extra space on the end of lines. For empty lines, this would delete all space contained within them. Any ideas?
Record a macro that does that as a find & replace, then saves the file. Set it to ⌘S.
On Sep 10, 2007, at 2:04 PM, Michael Sheets wrote:
On Sep 10, 2007, at 11:51 AM, Michael Jackson wrote:
I'm looking for a way to delete all extra space from a file on save. Extra space would include extra space on the end of lines. For empty lines, this would delete all space contained within them. Any ideas?
Record a macro that does that as a find & replace, then saves the file. Set it to ⌘S.
Thanks for the idea. I can get the first part to work, but I can't seem to get the macro to save the file for me. I've tried using the menu command as well as the keyboard shortcut while recording the macro and neither seem to work. Any idea why?
Thanks,
Michael
Try editing the macro plist by hand to add save: as an action.
On Sep 11, 2007, at 12:13 AM, Michael Jackson wrote:
On Sep 10, 2007, at 2:04 PM, Michael Sheets wrote:
On Sep 10, 2007, at 11:51 AM, Michael Jackson wrote:
I'm looking for a way to delete all extra space from a file on save. Extra space would include extra space on the end of lines. For empty lines, this would delete all space contained within them. Any ideas?
Record a macro that does that as a find & replace, then saves the file. Set it to ⌘S.
Thanks for the idea. I can get the first part to work, but I can't seem to get the macro to save the file for me. I've tried using the menu command as well as the keyboard shortcut while recording the macro and neither seem to work. Any idea why?
On Sep 11, 2007, at 3:14 AM, Kevin Ballard wrote:
Try editing the macro plist by hand to add save: as an action.
Thanks for the idea. I tried but I can't seem to get it to work. Here's what my macro plist looks like:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http:// www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>commands</key> <array> <dict> <key>argument</key> <dict> <key>action</key> <string>replaceAll</string> <key>findInProjectIgnoreCase</key> <false/> <key>findString</key> <string>[\s\t[^\n]]+\n</string> <key>ignoreCase</key> <false/> <key>regularExpression</key> <true/> <key>replaceAllScope</key> <string>document</string> <key>replaceString</key> <string>\n</string> <key>wrapAround</key> <true/> </dict> <key>command</key> <string>findWithOptions:</string> </dict> <dict> <key>argument</key> <dict> <key>action</key> <string>save</string> </dict> <key>command</key> <string>save:</string> </dict> </array> <key>keyEquivalent</key> <string>@e</string> <key>name</key> <string>Remove Extra Space</string> <key>uuid</key> <string>827CEB8B-09BD-49A5-948E-02E4A56D11C7</string> </dict> </plist>
I added the second <dict> node myself (just following the pattern) but it doesn't work. Is there something wrong with my syntax? Have you gotten this to work?
Thanks,
Michael
On 11/09/2007, Michael Jackson mjijackson@gmail.com wrote:
On Sep 11, 2007, at 3:14 AM, Kevin Ballard wrote:
Try editing the macro plist by hand to add save: as an action.
Thanks for the idea. I tried but I can't seem to get it to work. Here's what my macro plist looks like:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http:// www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <dict> <key>commands</key> <array> <dict> <key>argument</key> <dict> <key>action</key> <string>replaceAll</string> <key>findInProjectIgnoreCase</key> <false/> <key>findString</key> <string>[\s\t[^\n]]+\n</string> <key>ignoreCase</key> <false/> <key>regularExpression</key> <true/> <key>replaceAllScope</key> <string>document</string> <key>replaceString</key> <string>\n</string> <key>wrapAround</key> <true/> </dict> <key>command</key> <string>findWithOptions:</string> </dict> <dict> <key>argument</key> <dict> <key>action</key> <string>save</string> </dict> <key>command</key> <string>save:</string> </dict> </array> <key>keyEquivalent</key> <string>@e</string> <key>name</key> <string>Remove Extra Space</string> <key>uuid</key> <string>827CEB8B-09BD-49A5-948E-02E4A56D11C7</string> </dict> </plist>
I added the second <dict> node myself (just following the pattern) but it doesn't work. Is there something wrong with my syntax? Have you gotten this to work?
Thanks,
Michael
This is what I use.
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>bundleUUID</key> <string>4D3A1152-0146-4398-B0EE-A5D8DC59A82E</string> <key>commands</key> <array> <dict> <key>argument</key> <dict> <key>beforeRunningCommand</key> <string>nop</string> <key>command</key> <string>perl -pe 's/[\t ]+$//g'</string> <key>fallbackInput</key> <string>document</string> <key>input</key> <string>selection</string> <key>name</key> <string>Remove Trailing Spaces in Document / Selection</string> <key>output</key> <string>replaceSelectedText</string> <key>uuid</key> <string>0F8C1F78-6E4C-11D9-91AF-000D93589AF6</string> </dict> <key>command</key> <string>executeCommandWithOptions:</string> </dict> <dict> <key>argument</key> <dict> <key>beforeRunningCommand</key> <string>saveActiveFile</string> <key>input</key> <string>none</string> <key>output</key> <string>discard</string> </dict> <key>command</key> <string>executeCommandWithOptions:</string> </dict> </array> <key>keyEquivalent</key> <string>^~@s</string> <key>name</key> <string>Strip trailing and save</string> <key>uuid</key> <string>89723925-4AB6-4DC2-939F-E8A0188CDEF7</string> </dict> </plist>
On Sep 11, 2007, at 9:09 AM, Sven Axelsson wrote:
<dict> <key>argument</key> <dict> <key>beforeRunningCommand</key> <string>saveActiveFile</string> <key>input</key> <string>none</string> <key>output</key> <string>discard</string> </dict> <key>command</key> <string>executeCommandWithOptions:</string> </dict>
Excellent! This did the trick. Thanks!
Michael