The Visual Studio Code Ballerina extension provides a set of rich language features along with an enhanced user experience. It offers easy development, execution, debugging, and testing for the Ballerina programming language. You can further visualize the graphical representation of your Ballerina source via the Diagram Editor.
Setting up the Prerequisites
Tip: The VSCode Ballerina extension supports both the Ballerina Swan Lake and 1.2.x versions.
Installing the Ballerina Extension
Follow the steps below to install the Ballerina extension.
Go to the Ballerina extension in the Visual Studio Code Marketplace, and click Install.
Click Open Visual Studio Code and install the extension.
Tip: To verify if the extension is installed, check if the Ballerina SDK Version is displayed on the VSCode status bar. If you get
Ballerina SDK: Erroror
Ballerina SDK: Detectingon the status bar, enable extension debug logs to troubleshoot.
Running Your First Ballerina Program
Follow the steps below to create a sample Ballerina program in VSCode.
Click View in the menu bar of the editor, and click Command Palette.
Tip: You can use the shortcut methods
⌘ + ↑ + Pon Mac and
Ctrl + Shift + Pon Windows and Linux.
In the search bar, type
Ballerina Examplesand click Ballerina: Show Examples.
Select the Hello World Main example.
Click on the Run code lens on the editor.
You just ran your first Ballerina program with a few clicks.
Tip: If you wish to debug further, you can either use the Debug code lens or see Run and Debug.
Click the Show Diagram View button on the editor’s title bar to view the graphical representation of the program.
The VS Code Ballerina extension is enriched with language support capabilities and user configuration support. For more information on these capabilities, see the sections below.