Can anybody help me to write a macro to reeindent all the files in a directory with the current indentation settings? Thanks.
That's an interesting question. My mind is going places like indenting code based If-Then-Else etc. Is this what you mean?
If it's just putting one indent at the beginning of each line in all files, it should be easy with Replace in Files:
Replace:
^(.)
With:
\t\1
(Replace the first character on each line with tab followed by that character.)
Make sure Unix RE are on.
A word of caution: make sure this is what you want to do first, because it will change every line of every file you designate!
Dave
If it's just putting one indent at the beginning of each line in all files, it should be easy with Replace in Files:
Replace:
^(.)
With:
\t\1
(Replace the first character on each line with tab followed by that character.)
Make sure Unix RE are on.
A word of caution: make sure this is what you want to do first, because it will change every line of every file you designate!
Dave
ASTTMan
I'm not a Texan, I just live here.
I'm not a Texan, I just live here.
omfollett likes this post
I use the open source program 'Artistic Style' for indentation of C, C++ and Java files. It can be downloaded from SourceForge (https://sourceforge.net/projects/astyle/).
I added a project tool entry with following data:
Command Line: "C:\Programs\util_astyle\astyle.exe" --mode=c --style=ansi --indent=spaces=3 --indent-switches %F
Working Directory: U:\dev\sw\source\app
Menu Item Name: Indent Current File
What I'm still looking for is a way to execute this command on file load or save. I tried to install a macro that executes the project tool, but it doesn't seem to work properly. Any ideas?
I added a project tool entry with following data:
Command Line: "C:\Programs\util_astyle\astyle.exe" --mode=c --style=ansi --indent=spaces=3 --indent-switches %F
Working Directory: U:\dev\sw\source\app
Menu Item Name: Indent Current File
What I'm still looking for is a way to execute this command on file load or save. I tried to install a macro that executes the project tool, but it doesn't seem to work properly. Any ideas?
I'll look into the 'Artistic Style'. I've read some other comments about it in the forum.
As for running the tool from a macro, I assume you tried the "RunTool" macro command. If you can get it to run from a macro, you could, designate that macro to run on the Macro | Set Macro for File Load/Save menu. I haven't tried this, but it seems like it should work.
Good Luck!
Dave
As for running the tool from a macro, I assume you tried the "RunTool" macro command. If you can get it to run from a macro, you could, designate that macro to run on the Macro | Set Macro for File Load/Save menu. I haven't tried this, but it seems like it should work.
Good Luck!
Dave
ASTTMan
I'm not a Texan, I just live here.
I'm not a Texan, I just live here.
Yes, I used RunTool "Indent Current File" in the macro. However, it looks like UltraEdit loads the file and executes the macro. The changes to file are however not apparent unless I switch to a different application/desktop and then back to UltraEdit. UE tells me then that the file was modified by an other application.
This makes sense because astyle creates a copy of the file. I guess I will attach the macro to the save command and not to the load command.
Thanks for your help!
This makes sense because astyle creates a copy of the file. I guess I will attach the macro to the save command and not to the load command.
Thanks for your help!
Good! I'm glad it worked.
Since you suggested the Project Tool configuration, I decided to give it a try, also. I am writing a Perl script, so I made a tool to run the script. The script creates an output file, which I edited.
When I run the script a second time, I got the same behavior you described! I have to change applications, then go back to UltraEdit to see the changes. Like you say, this makes sense.
Thanks for the ideas!
Dave
Since you suggested the Project Tool configuration, I decided to give it a try, also. I am writing a Perl script, so I made a tool to run the script. The script creates an output file, which I edited.
When I run the script a second time, I got the same behavior you described! I have to change applications, then go back to UltraEdit to see the changes. Like you say, this makes sense.
Thanks for the ideas!
Dave
ASTTMan
I'm not a Texan, I just live here.
I'm not a Texan, I just live here.