Quick Start

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

Before getting started, make sure you have installed the Visual Studio Code editor and Ballerina.

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.

Installing the Ballerina Extension

  1. Go to the Ballerina extension in the Visual Studio Code Marketplace, and click Install.

  2. 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: Error or Ballerina SDK: Detecting on the status bar, enable extension debug logs to troubleshoot.

Diagrams View

Running Your First Ballerina Program

Follow the steps below to create a sample Ballerina program in VSCode.

Running Your First Ballerina Program

  1. Click View in the menu bar of the editor, and click Command Palette.

    Tip: You can use the shortcut methods ⌘ + ↑ + P on Mac and Ctrl + Shift + P on Windows and Linux.

  2. In the search bar, type Ballerina Examples and click Ballerina: Show Examples.

  3. Select the Hello World Main example.

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

  5. Click the Show Diagram button on the editor’s title bar to view the graphical representation of the program.

What’s Next?

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.