Documentation

Python Editor

The Python editor is the heart of the QuantCraft IDE (Workspace layout). It opens whenever you select a file in the Files Sidebar or open a tab in the editor strip, and it gives you a complete, modern coding experience tuned for writing Python trading strategies. Manage libraries under Packages (Dependencies); run code with Run / Test (Running code).

This page covers the four areas you'll use most:


Editing

When a file is open, the editor fills the center of the IDE Main Panel and behaves like the Python editors you're already used to.

Writing code

  • Syntax highlighting for Python, with colors driven by the editor theme you choose.
  • Smart indentation — pressing Enter at the end of a line indents the next line correctly for Python (after def, class, if, for, with, etc.).
  • Line wrapping — long lines wrap visually so you don't have to scroll horizontally. The actual content is unchanged.
  • Spell‑check is off inside the editor, so identifiers and keywords don't get underlined.
  • Tabs insert 4 spaces.

Autocomplete

The editor offers context‑aware suggestions as you type:

  • Snippets for common Python patterns: def, class, for, while, try, with, lambda, import, from, ifmain, etc.
  • Standard library and installed packages — typing import or from suggests modules from the IDE's Python environment plus your own workspace folders and files.
  • Member completion — typing . after a module, package, or known QuantCraft object (for example bar., qc_ohlcv., fundamentals., pd.) lists the available attributes and methods.
  • Suggestions appear automatically; you can also trigger them explicitly with Ctrl+Space.
  • Ctrl+Click (or Cmd+Click on macOS) on an import or a workspace symbol jumps to that file in the editor and places the cursor on the matching line.
  • Each tab remembers its own scroll position and cursor location between visits, so switching files always brings you back exactly where you left off.

Find & Replace

A built‑in search panel sits at the top of the editor:

  • FindCtrl+F (or use Edit → Find).
  • ReplaceCtrl+H (or use Edit → Replace).
  • The replace row only appears when the file is editable.

Standard editing commands

All standard editing actions are available from the Edit menu in the editor toolbar and via keyboard shortcuts:

ActionShortcut
UndoCtrl+Z
RedoCtrl+Y
CutCtrl+X
CopyCtrl+C
PasteCtrl+V
FindCtrl+F
ReplaceCtrl+H
Format DocumentShift+Alt+F

Tip: copy and paste use your system clipboard, so you can move code between QuantCraft and any other app.


Themes

The editor's color theme is independent from the rest of the app — you can run the app in dark mode and still use a light editor theme, or vice versa.

Changing the theme

  1. Open the editor toolbar at the top of the editor.
  2. Click Theme.
  3. Pick a theme from the list. The editor updates immediately.

Your choice is saved automatically and restored the next time you open the IDE.

Available themes

The Theme menu includes a curated set of light and dark themes:

  • Default Light, Default Dark
  • VS Code Light, VS Code Dark (VS Code Dark is the default)
  • GitHub Light, GitHub Dark
  • Dracula
  • Monokai
  • Nord
  • Solarized Light, Solarized Dark
  • Tokyo Night
  • Gruvbox Dark
  • Material Light, Material Dark

A check mark in the menu shows which theme is currently active.


Font size

You can pick the editor font size to match your screen and your eyes — without changing font sizes anywhere else in the app.

Changing the font size

  1. Open the editor toolbar.
  2. Click Font Size.
  3. Pick a size. The editor re‑renders immediately at the new size.

Your choice is remembered between sessions.

Available sizes

11 px, 12 px, 13 px, 14 px (default), 15 px, 16 px, 18 px, 20 px, 22 px.

A check mark in the menu shows the active size.


Format Document

Format Document tidies up the whole file for you in one step — useful before committing changes, sharing code, or just keeping a strategy readable while you work.

How to run it

  • Open the Edit menu in the editor toolbar and choose Format Document, or
  • Press Shift+Alt+F while the editor is focused.

What it does

  • For Python files, the editor formats your code using QuantCraft's built‑in Python formatter.
  • For JSON files, the editor pretty‑prints the JSON (with 2‑space indentation). Newline‑delimited JSON is also recognized and each line is normalized.
  • If the file isn't valid Python or JSON, formatting falls back to the Python formatter so you still get a useful error.

Where errors show up

If a file can't be formatted (for example because of a syntax error), the editor leaves your code untouched and writes the error message to the Output Panel at the bottom of the workspace, marked in red. Fix the reported issue and run Format Document again.

Tips

  • Format Document does not save the file — it just rewrites the buffer. Use File → Save As… if you need to save under a new name.
  • Undo (Ctrl+Z) reverses a format in one step if you don't like the result.
  • The format command is also wired into the editor itself, so the Shift+Alt+F shortcut works whether you're in the menu or typing in the code.