Code Formatting

Overview

This section provides detailed instructions on how to format your code within the Servoy Scripting Editor. It covers automatic code formatting on save, setting project-specific formatting profiles, and force formatting multiple projects. These features help ensure consistent code style across your development team, enhancing readability and maintainability of the codebase.

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:

  1. In Solution Explorer, select the currently active project and access the context menu (right-click).

  2. Click on Properties at the bottom.

  3. In the Javascript node, under Editor, click on Save Actions.

  4. Click the checkbox to Enable project specific settings. The checkbox option for Format source code on save will be un-grayed.

  5. 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:

  1. In Solution Explorer, select the currently active project and access the context menu (right-click).

  2. Click on Properties at the bottom.

  3. In the Javascript node, under Editor, click on Formatter.

  4. Click the checkbox to Enable project specific settings.

  5. 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.

Force Formatting the Code Base of Entire Projects

Several projects can be formatted at once using the following steps:

  1. Open the Script Explorer View using the main menu Window > Show View > Other > Dynamic Languages > Script Explorer.

  2. Select the project(s) on which you want to perform the formatting.

  3. Right-click to access the context menu (make sure your mouse pointer is hovering on top of a selected project).

  4. Click on the menu item Source > Format.

Last updated