Author Topic: Beautifier  (Read 6424 times)

yop

  • Community Member
  • Posts: 5
  • Hero Points: 1
Beautifier
« on: June 29, 2008, 08:53:05 pm »
Using the beautifier on C++ I always get the last empty line clipped resulting on compiler warnings. Hoe can I change this behavior?  The beautifier options  don't seem to include something relevant.

Graeme

  • Senior Community Member
  • Posts: 2364
  • Hero Points: 312
Re: Beautifier
« Reply #1 on: June 30, 2008, 11:43:26 am »
Using the beautifier on C++ I always get the last empty line clipped resulting on compiler warnings. Hoe can I change this behavior?  The beautifier options  don't seem to include something relevant.

Record a macro that does
1. Go to bottom of file
2. Go to end of line
3. Press ENTER
4. Select tools -> beautify
5. Save the file (optional)
6. End macro recording and give the macro a name

You'll get a macro that looks like the following.  You can bind a key to it or add it to a menu or just execute from the command line or from macro -> list macros.

Code: [Select]
_command beautify_2() name_info(','VSARG2_MACRO|VSARG2_MARK|VSARG2_REQUIRES_MDI_EDITORCTL)
{
   _macro('R',1);
   bottom_of_buffer();
   end_line();
   c_enter();
   execute('gui_beautify');
}

Graeme

yop

  • Community Member
  • Posts: 5
  • Hero Points: 1
Re: Beautifier
« Reply #2 on: June 30, 2008, 04:27:46 pm »
After trying it, it has a couple of problems:
* It leaves the caret in the last line of the file.
* The beautifier does not delete the last empty line (probably because the caret is there), so lines just keep getting appended

Graeme

  • Senior Community Member
  • Posts: 2364
  • Hero Points: 312
Re: Beautifier
« Reply #3 on: July 01, 2008, 12:26:47 am »
After trying it, it has a couple of problems:
* It leaves the caret in the last line of the file.
* The beautifier does not delete the last empty line (probably because the caret is there), so lines just keep getting appended

ok, try this.

Code: [Select]
_command void beautify_2() name_info(','VSARG2_MACRO|VSARG2_MARK|VSARG2_REQUIRES_MDI_EDITORCTL)
{
   _macro('R',1);
   typeless p;
   _str line;
   execute('gui_beautify');
   _save_pos2(p);
   bottom_of_buffer();
   get_line(line);
   if (line != '') {
      end_line();
      c_enter();
   }
   _restore_pos2(p);
}

Graeme