Here is the combination of MACRO and TOOL that i use to let me select a block of text in a file and process it by an external exe program, capture the output and paste it back replacing the originally selected text.
The key feature of this technique is that it allows you to use an easy undo to undo the change (Ctrl+Z) and preserves your place in the file after the operation.
The sample tool below runs the open source Astyle exe (C++ coder formatter) on the selected block, and is configured to implement whitesmith style c++ indentation (
http://en.wikipedia....le#Whitesmiths_style), which i love.
MyAstyle MACRO
-------------------------
InsertMode
ColumnModeOff
HexOff
UnixReOff
Copy
NewFile
Paste
SaveAs "C:\Temp\Astyle.tmp"
CloseFile
RunTool "MyAstyle"
Open "C:\Temp\Astyle.tmp"
SelectAll
Copy
CloseFile
ToggleBookmark
Paste
Open "C:\Temp\Astyle.tmp.orig"
SelectAll
Copy
CloseFile
PreviousBookmarkSelect
ToggleBookmark
MyAstyle TOOL Configuration:
-----------------------------
COMMANDLINE -> D:\Libraries\astyle\astyle.exe --mode=c --indent-brackets --brackets=break --indent=tab --one-line=keep-blocks --one-line=keep-statements C:\Temp\Astyle.tmp
WORKINGDIR -> C:\Temp\
MENUITEMNAME-> MyAstyle
DONT CHECK "CAPTURE OUTPUT" - this has the exe write output to a file.
if your exe outputs to stdout, then you should check "capture output" and modify the macro and remove the lines from the first Open to the subsequent Closefile.