Files ending in .worksheet.kts can be run with Kotlin Worksheet: Run. By default, worksheet files also run when saved.
val x = 40 // => 40
x + 2 // => 42
println("hello") // => hello
Requirements
VS Code 1.100 or newer
A local Kotlin compiler on PATH, or configure kotlinWorksheet.kotlinCommand
Kotlin syntax highlighting from a Kotlin language extension. This extension packs fwcd.kotlin.
Supported Kotlin compiler for CI and local examples: kotlinc-jvm 2.4.0.
Use kotlinWorksheet.executionMode to choose between local kotlinc, Gradle classpath resolution, or automatic detection.
Install For Users
Install from a local VSIX:
Download or build kotlin-worksheet-0.3.0.vsix.
Open VS Code.
Run Extensions: Install from VSIX... from the Command Palette.
Select kotlin-worksheet-0.3.0.vsix.
Open a trusted workspace.
Create a file ending in .worksheet.kts.
Run Kotlin Worksheet: Run.
Install the Kotlin compiler if kotlinc -version does not work in your terminal. After installing Kotlin, restart VS Code so the extension can see the updated PATH.
Commands
Kotlin Worksheet: Run
Kotlin Worksheet: Rerun
Kotlin Worksheet: Clear Results
Kotlin Worksheet: New Worksheet
Kotlin Worksheet: Toggle Run On Save
Kotlin Worksheet: Toggle Render Mode
Settings
kotlinWorksheet.kotlinCommand: command used to run Kotlin scripts, default kotlinc
kotlinWorksheet.runOnSave: run .worksheet.kts files on save, default false
kotlinWorksheet.renderMode: show results as inlineComments or decorations, default inlineComments
kotlinWorksheet.executionMode: choose auto, localKotlinc, or gradleClasspath, default auto
kotlinWorksheet.timeoutMs: execution timeout in milliseconds, default 10000
Development
pnpm install
pnpm compile
pnpm test
Run the full local verification before packaging or release: