9.1. Pretty PrinterΒΆ

The command “Pretty Print” allows you to format Ada source files using a number of language-specific options. The command is provided in the Ada menu on the menubar and in the contextual menus of the editor and the GNAT Project Explorer.

Note that in addition to formatting individual files, you can format all the files in an entire project by selecting the project node in the GNAT Project Explorer.

The actual formatting is provided by the external tool “gnatpp”, with switches specified in the GNAT project file. You can either edit the project file manually, as usual, or use the GNAT Project GUI properties editor to set them.

If you edit the GNAT project file manually, the package corresponding to the tool is named “Pretty_Printer” and it uses the Default_Switches attribute for language “Ada”. The following GNAT project file fragment provides an example:

pretty printer switches in gpr file

As usual it will be easier to use the interactive dialog to set the switches. To invoke the dialog, select GNAT Project -> Edit Properties from the GNAT Project Explorer’s contextual menu. The dialog will appear as follows:

pretty printer switches in project editor