Up to date

This page is up to date for Godot 4.1. If you still find outdated information, please open an issue.

Visual Studio Code

Visual Studio Code is a free cross-platform code editor by Microsoft (not to be confused with Visual Studio).

Importing the project

  • Make sure the C/C++ extension is installed. You can find instructions in the official documentation. Alternatively, clangd can be used instead.

  • When using the clangd extension, run scons compiledb=yes.

  • From the Visual Studio Code’s main screen open the Godot root folder with File > Open Folder….

  • Press Ctrl + Shift + P to open the command prompt window and enter Configure Task.

../../../_images/vscode_configure_task.png

  • Select the Create tasks.json file from template option.

../../../_images/vscode_create_tasksjson.png

  • Then select Others.

../../../_images/vscode_create_tasksjson_others.png

  • If there is no such option as Create tasks.json file from template available, either delete the file if it already exists in your folder or create a .vscode/tasks.json file manually. See Tasks in Visual Studio Code for more details on tasks.

  • Within the tasks.json file find the "tasks" array and add a new section to it:

    1. {
    2. "label": "build",
    3. "group": "build",
    4. "type": "shell",
    5. "command": "scons",
    6. "args": [
    7. // enable for debugging with breakpoints
    8. "dev_build=yes",
    9. ],
    10. "problemMatcher": "$msCompile"
    11. }

../../../_images/vscode_3_tasks.json.png

An example of a filled out tasks.json.

Arguments can be different based on your own setup and needs. See Introduction to the buildsystem for a full list of arguments.

Debugging the project

To run and debug the project you need to create a new configuration in the launch.json file.

  • Press Ctrl + Shift + D to open the Run panel.

  • If launch.json file is missing you will be prompted to create a new one.

../../../_images/vscode_1_create_launch.json.png

  • Select C++ (GDB/LLDB). There may be another platform specific option here. If selected, adjust the configuration example provided accordingly.

  • Within the launch.json file find the "configurations" array and add a new section to it:

LinuxBSDLinuxBSD_gdbWindows

  1. {
  2. "name": "Launch Project",
  3. "type": "lldb",
  4. "request": "launch",
  5. // Change to godot.linuxbsd.tools.64.llvm for llvm-based builds.
  6. "program": "${workspaceFolder}/bin/godot.linuxbsd.editor.dev.x86_64",
  7. // Change the arguments below for the project you want to test with.
  8. // To run the project instead of editing it, remove the "--editor" argument.
  9. "args": [ "--editor", "--path", "path-to-your-godot-project-folder" ],
  10. "stopAtEntry": false,
  11. "cwd": "${workspaceFolder}",
  12. "environment": [],
  13. "externalConsole": false,
  14. "preLaunchTask": "build"
  15. }
  1. {
  2. "name": "Launch Project",
  3. "type": "cppdbg",
  4. "request": "launch",
  5. // Change to godot.linuxbsd.tools.64.llvm for llvm-based builds.
  6. "program": "${workspaceFolder}/bin/godot.linuxbsd.editor.dev.x86_64",
  7. // Change the arguments below for the project you want to test with.
  8. // To run the project instead of editing it, remove the "--editor" argument.
  9. "args": [ "--editor", "--path", "path-to-your-godot-project-folder" ],
  10. "stopAtEntry": false,
  11. "cwd": "${workspaceFolder}",
  12. "environment": [],
  13. "externalConsole": false,
  14. "setupCommands":
  15. [
  16. {
  17. "description": "Enable pretty-printing for gdb",
  18. "text": "-enable-pretty-printing",
  19. "ignoreFailures": true
  20. }
  21. ],
  22. "preLaunchTask": "build"
  23. }
  1. {
  2. "name": "Launch Project",
  3. "type": "cppvsdbg",
  4. "request": "launch",
  5. "program": "${workspaceFolder}/bin/godot.windows.editor.dev.x86_64.exe",
  6. // Change the arguments below for the project you want to test with.
  7. // To run the project instead of editing it, remove the "--editor" argument.
  8. "args": [ "--editor", "--path", "path-to-your-godot-project-folder" ],
  9. "stopAtEntry": false,
  10. "cwd": "${workspaceFolder}",
  11. "environment": [],
  12. "console": "internalConsole",
  13. "visualizerFile": "${workspaceFolder}/platform/windows/godot.natvis",
  14. "preLaunchTask": "build"
  15. }

../../../_images/vscode_2_launch.json.png

An example of a filled out launch.json.

Note

Due to sporadic performance issues, it is recommended to use LLDB over GDB on Unix-based systems. Make sure that the CodeLLDB extension is installed.

If you encounter issues with lldb, you may consider using gdb (see the LinuxBSD_gdb configuration).

Do note that lldb may work better with LLVM-based builds. See Compiling for Linux, *BSD for further information.

The name under program depends on your build configuration, e.g. godot.linuxbsd.editor.dev.x86_64 for 64-bit LinuxBSD platform with platform=editor and dev_build=yes.

If you run into any issues, ask for help in one of Godot’s community channels.

Tip

To get linting on class reference XML files, install the vscode-xml extension.