Author Topic: How to beautify all files in a project automatically?  (Read 5812 times)

count0

  • Junior Community Member
  • Posts: 2
  • Hero Points: 0
How to beautify all files in a project automatically?
« on: November 18, 2006, 03:44:07 am »

Currently if I want beautify all files in a project, I have to open them one by one and invoke tools->beautify, it is tedious.

So I want to beatify them in same time automatically, is there such a command or macro? or how to write such a macro?






Graeme

  • Senior Community Member
  • Posts: 2017
  • Hero Points: 236
Re: How to beautify all files in a project automatically?
« Reply #1 on: November 18, 2006, 12:03:21 pm »
See this thread where Clark described how to use the file manager to apply a command to a list of files
http://community.slickedit.com/index.php?topic=481.0

You can't use the file manager to display a list of project files as far as I know, but you can use the following macro to beautify all open buffers.  c_beautify seems to handle several different file extensions but not necessarily all the file types in your project.  The fourth parameter set true selects quiet mode which might not be what you want.  You could use the project toolbar to open files from your project that have a particular extension, or use the "open project files" option on the project menu.

Warning - this code worked for me so it probably should for you, but I strongly recommended you backup all your files first.  It doesn't save any files but you can use the save-all command (type save-all on the command line) or right click a file tab and choose save all.

c_beautify can return an error code, in which case you might need to make the beautify_this_buffer function check for the error and return a non zero value if you want to stop iterating through open buffers.  You can find c_beautify and for_each_buffer in the slick help file.

Copy this code into vusrmacs.e file (in your config folder) and load it with the load module command on the macro menu.  Then type beautify_open_buffers on the cmd line to run it.  Once you've loaded the macro you'll find it listed in the key bindings dialog where you can bind a key to it if you want.

Code: [Select]
int beautify_this_buffer()
{
   c_beautify(0,0,false,true);
   return 0;
}

_command void beautify_open_buffers() name_info(',')
{
   for_each_buffer('beautify_this_buffer');
}

Graeme
« Last Edit: November 18, 2006, 12:08:33 pm by Graeme »

count0

  • Junior Community Member
  • Posts: 2
  • Hero Points: 0
Re: How to beautify all files in a project automatically?
« Reply #2 on: November 18, 2006, 01:03:50 pm »
@Graeme
Your macro works like a charm, thanks for it and the helpful explanation.


banslow

  • Community Member
  • Posts: 7
  • Hero Points: 0
Re: How to beautify all files in a project automatically?
« Reply #3 on: June 25, 2010, 03:07:51 pm »
Hi,
I realize this is an "old" Topic, but I was wondering what the parameters to c_beautify() are - I cannot find the definition of c_beautify() in the Help (I get a page not found error).

VisualSlickEdit 2010..

Thanks,

Bryan.
 

banslow

  • Community Member
  • Posts: 7
  • Hero Points: 0
Re: How to beautify all files in a project automatically?
« Reply #4 on: June 25, 2010, 03:53:00 pm »
OK, never mind...

I found an explanation of the parameters if I click on c_beautify in Options -> Keyboard & mouse -> Key Bindings

Bryan.