Visual Studio Code for LSL

VS Code Logo

This is a brief guide on setting up Visual Studio Code in Windows for creating LSL scripts for Second Life. I am by no means an expert with Visual Studio Code and would like to thank Coal Edge for a lot of tips and info used in this guide. The end goal is to get as close to Eclipse with LSLForge as currently possible (minus the simulation features). You will be able to create your LSL files with syntax highlighting and use external tools to preprocess the script (for #includes) and to optimize your scripts using LSL-PyOptimizer.

You could use the Firestorm preprocessor but I feel like doing all your code preprocessing, editing, and optimizing externally from Firestorm has a better workflow – at least for me.

The below assumes some basic understanding of Visual Studio Code so it’s a fairly brief set of instructions – you may need to read through the extension descriptions on their marketplace pages or other linked documentation for more info on how to accomplish certain tasks.

  • Install the following VS Code extensions:
    • TextMate Languages
    • LSL-FP
      1. Update with snippets.json from (or a more recent fork if available). This will give you more recent auto-complete/intellisense data.
      2. Generate Sublime tmLanguage files with – I created a Ubuntu virtual machine for this and installed the required modules listed on the GitHub page above. Then run the script. This is probably the trickiest part of these instructions.
      3. Convert the lsl.tmLanguage file generated in the last step to lsl.tmLanguage.json using the TextMate Languages extension you installed at the beginning (see marketplace page for command for this).
      4. Replace lsl.tmLanguage.json with converted file from above. (located in ‘%USERPROFILE%\.vscode\extensions\dalghost.lsl-fp-XYZ’ in Windows, where XYZ is the version number).
    • LSLint For VSCode (doesn’t yet support #includes)
      • Use this for real-time syntax checking (linting) of LSL files in VS Code. If you want to use #includes, they are not supported with this.
    • Add other extensions as desired.

Next, we’ll set up a folder in Windows to store our tools for processing our LSL files.

  • Create directory “C:\SL” (if you use a different directory, update paths as required below).
  • Add “C:\SL” to Windows path (see this tutorial)
  • Copy mcpp.exe to “C:\SL” directory. This is a preprocessor that will allow you to include other .lsl files into your code with #include “filename.lsl” at the top of the file. It has other features, but I mainly just use it for the includes.
  • Extract LSL-PyOptimizer contents (or git clone) to “C:\SL\LSL-PyOptimizer” directory.
  • Install Python 2.7 (or whichever is compatible with current version of LSL-PyOptimizer).
  • Create a custom task in VS Code

Replace contents of tasks.json file with the below (it will be in a .vscode folder in your project after creating a custom task above):

    // See
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
            "label": "LSL-Optimize",
            "command": "python",
            "group": {
                "kind": "build",
                "isDefault": true
            "args": [
            "presentation": {
                "echo": true,
                "panel": "shared",
                "focus": true,
                "clear": true,
                "showReuseMessage": false

There are a few settings we need to tweak to tie everything together.

In VS Code, File > Preferences > Settings > search “terminal right click”
Set Terminal Integrated Right Click to default. This allows you to right-click and select all in the terminal pane which will allow you to copy the script output from LSL-PyOptimizer so you can paste it into a script in-world.

Run above custom task via Terminal > Run build task (or CTRL+SHIFT+B).

The end result is that when you finish working on your script in VS Code and run the build task, it will run it through LSL-PyOptimizer which is configured to preprocess the file with mcpp first, then output a memory-optimized LSL file to the terminal pane in VS Code. Then just select all of the output and copy it into a script in-world.

Some notes on #include directives for mcpp:
You may have to specify the include as an absolute path to make it work. Sometimes mcpp seems to have trouble finding the file to include, even if it’s in the same directory as the script that is including it. To quickly get the absolute path of the include file, hold SHIFT and right-click it in File Explorer, then select Copy as path. You can then paste it after the #include directive at the top of your script.

Some examples of #includes:

#include "myInclude.lsl"
// Basic include. Should work most of the time.

#include "C:\Path\To\myInclude.lsl"
// Absolute path to the include.
// This one might generate an error along the lines
// of 'Illegal UCN sequence' but still works. Likely due to the 
// unescaped backslashes

#include "C:\\Path\\To\\myInclude.lsl"
// Backslashes are escaped... kind of a pain.
// I prefer the one below to escaping the backslashes.

#include <C:\Path\To\myInclude.lsl>
// This one seems to deal with the backslashes better