Editar

Compartilhar via


AL formatter

Note

We're working on improving the onboarding experience for AL developers. If you've input for this article, we'd love to hear from you. Please use the Feedback section at the bottom of this article to help us make improvements that you’d like to see.

We also welcome contributions to our docs. New to contributing to docs? Don't worry, read more about contributing here Contribute to the help.

The AL Language extension for Microsoft Dynamics 365 Business Central offers users the option to automatically format their source code. This capability increases the usability of the editor by allowing developers to instantly fix the indentation and formatting of their code. The autoformatter analyzes the syntax tree of the AL code that you're formatting. By using rules that are based on the coding and style guidelines for AL, the autoformatter then inserts and removes whitespace from key points in the document to make it more readable.

Note

The rules used by the autoformatter can't be configured by the user. This limitation is present to allow for a uniform style to be used throughout the community of AL developers.

Invoking AL formatter

The auto-formatter can be invoked to format an entire AL document or a pre-selected range. In an existing project, open the document that you want to format, right-click inside the document, and select Format Document. In the default configuration for Visual Studio Code, the command can be run using the shortcut Alt+Shift+F.

Format Document.

To format a range, in an already opened project, open the document that you want to modify, select the specific range to format, right-click, and select Format Selection. In the default configuration for Visual Studio Code, the command can be run using the shortcut Ctrl+K, Ctrl+F.

Format Selection.

See also

AL development environment
AL outline view
AL code actions