The Build extension integrates the Free Pascal Compiler (FPC) and pas2js into VS Code. It enables compilation, cleanup, and uses-clause formatting directly from the editor.
The Build extension provides:
| Command | Keyboard Shortcut | Description |
|---|---|---|
WvdS: Build Project | Ctrl+Shift+B | Compiles the current project |
WvdS: Clean Build | - | Deletes build artifacts |
WvdS: Rebuild Project | - | Clean + Build in one step |
WvdS: Format Uses Clauses | Ctrl+Alt+U | Formats uses clauses in the current file |
WvdS: Remove Unused Units | - | Removes unused units from uses |
Ctrl+Shift+B or run WvdS: Build Project| Type | Description | Usage |
|---|---|---|
| Build | Incremental build, only changed units | Normal development |
| Clean | Deletes all .o, .ppu, .exe files | For problems, before release |
| Rebuild | Clean + Build | Complete recompilation |
The extension automatically selects the correct compiler:
| File Extension | Compiler | Output |
|---|---|---|
| .lpr, .pas (with .lpi) | FPC via lazbuild | Native Binary |
| .dpr, .dpk | FPC | Native Binary |
| .pas (with pas2js.cfg) | pas2js | JavaScript |
The formatter organizes and cleans up uses clauses.
Before:
uses SysUtils,Classes,Forms, Dialogs, StdCtrls, Windows, MyUnit;
After (alphabetical, 2 spaces, 80 characters):
uses Classes, Dialogs, Forms, MyUnit, StdCtrls, SysUtils, Windows;
Right-click in a Pascal file shows the „Uses Clauses“ submenu:
{
"wvds.build.fpcPath": "",
"wvds.build.pas2jsPath": ""
}
{
// Sort order
// "alphabetical" | "lengthAsc" | "lengthDesc" | "none"
"wvds.usesFormatter.sortOrder": "alphabetical",
// Indentation (number of spaces)
"wvds.usesFormatter.indentSize": 2,
// Maximum line length
"wvds.usesFormatter.maxLineLength": 80,
// Group by type (RTL, LCL, Custom)
"wvds.usesFormatter.groupByType": false,
// Automatically remove unused units
"wvds.usesFormatter.removeUnused": false
}
| Option | Description | Example |
|---|---|---|
| alphabetical | A-Z sorting (default) | Classes, Dialogs, Forms, SysUtils |
| lengthAsc | Shortest first | DB, Forms, Classes, SysUtils |
| lengthDesc | Longest first | SysUtils, Classes, Forms, DB |
| none | Keep original order | - |
With grouping enabled (groupByType: true):
uses // RTL Classes, SysUtils, // LCL Forms, StdCtrls, // Custom MyUnit, AnotherUnit;
The extension parses compiler output and shows errors in the Problems panel.
FPC Format:
myunit.pas(42,10) Error: Identifier not found "TFoo"
pas2js Format:
myunit.pas(42,10) Error: identifier "TFoo" not found
F8 jumps to the next errorShift+F8 jumps to the previous error
Create a build.cfg in the project folder for project-specific settings:
[build] compiler=fpc target=windows-x64 mode=debug [debug] optimizations=off symbols=on assertions=on [release] optimizations=3 symbols=off assertions=off
| Option | Values | Description |
|---|---|---|
| compiler | fpc, pas2js, lazbuild | Compiler to use |
| target | windows-x64, linux-x64, web, … | Target platform |
| mode | debug, release | Build mode |
| optimizations | off, 1, 2, 3 | Optimization level |
| symbols | on, off | Generate debug symbols |
| assertions | on, off | Enable assertions |
| Action | Windows/Linux | macOS |
|---|---|---|
| Build Project | Ctrl+Shift+B | Cmd+Shift+B |
| Format Uses | Ctrl+Alt+U | Cmd+Alt+U |
Cause: FPC/pas2js not configured.
Solution:
WvdS: Toolchain Configuration…wvds.build.fpcPath in settings.jsonCause: Compiler output deviates from expected format.
Solution:
Cause: No uses clause found or file not supported.
Solution:
| Property | Value |
|---|---|
| Extension ID | wvds.wvds-vscode-build |
| Activation | onCommand, onLanguage:pascal |
| Dependencies | wvds-vscode-core |
| Min. VS Code | 1.85.0 |