Author Topic: Batch Beautify?  (Read 848 times)

rgloden

  • Senior Community Member
  • Posts: 133
  • Hero Points: 3
Batch Beautify?
« on: February 25, 2015, 12:31:28 am »
Is there a way to batch Beautify a set of files or maybe a whole project?

Graeme

  • Senior Community Member
  • Posts: 1978
  • Hero Points: 226
Re: Batch Beautify?
« Reply #1 on: February 25, 2015, 07:16:19 am »
Here's some code to beautify a project.  It auto saves the files.  Take out the call to save() if you want to manually save.

Code: [Select]
_command void xbeautify_project() name_info(',')
{
   _str files_to_beautify [];

   //_GetWorkspaceFiles(_workspace_filename, files_to_beautify);
   _getProjectFiles( _workspace_filename,_project_get_filename(), files_to_beautify, 1);

   int k;
   for (k = 0; k < files_to_beautify._length(); ++k) {
      if (edit("+B " :+ files_to_beautify[k]) == 0) {
         beautify();
         save();
      }
      else
      {
         edit(files_to_beautify[k]);
         beautify();
         save();
         quit();
      }
   }
}

See also this post.
http://community.slickedit.com/index.php?topic=481.0

A crude way to batch beautify could be a macro with a bunch of macro calls
   your_macro( "file1.cpp" );
   your_macro( "file2.cpp" );
or use execute_selection.