Source mode
Source mode turns the Studio into a code editor for your project: explorer, tabs, search and highlighting, plus language servers and Git on the desktop.
On this page
Source mode is the fourth Studio mode (Scene, Play, Build, Source). It turns the centre of the Studio into a code editor for the open project, built into the engine rather than a web page inside it, and it behaves the way VS Code does: the same layout, the same shortcuts and the same kinds of panels.
You use it to edit scripts, neo.toml and any other text file in the project. Saving a script that the game is running hot-reloads it; see The Scripts panel.
The layout#
When you choose Source, the centre becomes the code workbench and the Scene panel hides. The Explorer opens with the whole project tree expanded.
| Part | What it is |
|---|---|
| Activity bar | Down the left side: Explorer, Search, Source Control (with a badge counting changed files) and Outline. |
| Side bar | The active view. Drag its edge to resize it; Cmd+B hides and shows it. |
| Editor area | Tabs and editor groups. Split to the right with Cmd+\. Breadcrumbs show the file path and the symbol you're in. |
| Bottom panel | Problems, Output and Terminal join Assets and Console. |
| Status bar | Line and column, indentation, encoding, line endings and the language, plus the Git branch and problem counts on the desktop. |
Shortcuts on this page are as on macOS (Cmd, Option).
Explorer#
The Explorer shows the project's files with icons per file type. You can create files and folders, rename (F2), delete, copy and paste. It follows the active editor, selecting the file you're working on.
The editor#
- Tabs. A dot marks unsaved changes. Middle-click closes a tab. A file opened with a single click opens as a preview tab in italics, which becomes a normal tab when you edit it or double-click it. Cmd+Shift+T reopens a closed tab.
- Highlighting. Syntax colours, line numbers, the current line, indent guides, bracket-pair colours and the matching bracket.
- Multi-cursor. Option+click adds a cursor, Cmd+D adds the next match, Cmd+Shift+L selects every match, Option+Cmd+Up/Down adds a cursor above or below. Shift+Option+drag selects a column.
- Editing. Auto-closing brackets and quotes, auto-indent, toggle comment (Cmd+/), move a line (Option+Up/Down), copy a line (Shift+Option+Up/Down), delete a line (Cmd+Shift+K), undo and redo.
- Find and replace. Cmd+F finds and Option+Cmd+F replaces, with case, whole-word and regular-expression options and an "n of m" count.
- Navigation. Go to line (Ctrl+G), go to symbol (Cmd+Shift+O), quick open a file (Cmd+P) and the command palette (Cmd+Shift+P).
- Saving. Cmd+S saves, Option+Cmd+S saves all. Closing a file with unsaved changes asks first.
Search#
Search (Cmd+Shift+F) searches the whole project, with regular expression, case and whole-word options and include and exclude patterns. Results are grouped by file; click a match to open it there. You can also replace across files.
Language features (desktop)#
On the desktop, Source mode runs the language servers VS Code uses, such as rust-analyzer, taplo (TOML), typescript-language-server and pyright. They add:
- errors and warnings as squiggles, on hover and in Problems;
- hover information, completion with documentation and snippets, and signature help;
- go to definition (F12 or Cmd+click), peek definition and references (Option+F12, Shift+F12), rename (F2), format document, code actions (Cmd+.) and inlay hints.
Source control (desktop)#
On the desktop, Source Control shows your Git changes:
- a commit message box (Cmd+Enter commits) and Staged Changes, Changes and Merge Changes groups, with stage, unstage and discard per file;
- a quick diff in the gutter while you type (added, modified and deleted lines), with stage and revert for each change;
- a side-by-side or inline diff editor;
- a branch picker in the status bar, with switch, create, pull, push and sync;
- line blame on request.
In the browser Studio#
The browser Studio runs the same code editor against the project stored in your browser.
| Works in the browser | Desktop only |
|---|---|
| Explorer: new file and folder, rename, delete, copy, paste | Language servers (they run as separate processes) |
| Tabs, highlighting, multi-cursor, find and replace | Git: status, diff, commit (needs the git program and a repository) |
| Saving (to the browser's project store) | The terminal |
| Search across files | Greying out ignored files in the Explorer (the browser's copy already leaves them out) |
The browser Explorer shows the Studio's workspace: your projects, the templates and the samples' sources. The engine's own Rust sources aren't included, and Rust code can't be compiled in the browser; to change a project's Rust code and run it, use the desktop Studio.
Commands#
Source mode is driven by the same commands the menus and palette use, so agents can work in it too:
| Command | What it does |
|---|---|
source.open {path, line?, col?} | Opens a file, optionally at a line and column. |
source.state | The open files and the editor's state. |
source.edit | Edits a file. |
source.save | Saves. |
source.search | Searches the project. |
source.diagnostics | The current problems (desktop, from the language servers). |
source.command {id} | Runs any command palette command. |