Servoy provides options for code formatting. They are described in further detail in this chapter.
Formatting Code on Save
A project's code can be automatically formatted (line breaks, indentations, etc) on save. To do this, the project-specific settings must be activated:
- In Solution Explorer, select the currently active project and access the context menu (right-click).
- Click on Properties at the bottom.
- In the Javascript node, under Editor, click on Save Actions.
- Click the checkbox to Enable project specific settings. The checkbox option for Format source code on save will be un-grayed.
- Click the checkbox to Format source code on save.
Project-Specific Formatting
Different format profiles can be set for different projects. The information is saved to the SVN in team development environments, allowing all developers working on a project to use the same format profile.
To set a project-specific format profile:
- In Solution Explorer, select the currently active project and access the context menu (right-click).
- Click on Properties at the bottom.
- In the Javascript node, under Editor, click on Formatter.
- Click the checkbox to Enable project specific settings.
- Select a profile from the Drop-down list, or create/import a new profile using the respective buttons. (Note that you can also click on Edit to edit the default format profile.)
Note: If you select New, you will be prompted to type in a Profile name with the option to open the Edit Profile dialog. This dialog provides customizable options for general settings, Indents, Braces, White Space, and Control Statements. See image below. |
Force Formatting the Code Base of Entire Projects
Several projects can be formatted at once using the following steps:
- Open the Script Explorer View using the main menu Window > Show View > Other > Dynamic Languages > Script Explorer.
- Select the project(s) on which you want to perform the formatting.
- Right-click to access the context menu (make sure your mouse pointer is hovering on top of a selected project).
- Click on the menu item Source > Format.