MenuEveryday / The editor

Docs / Everyday

The editor

The editor suggests names, shows types, underlines mistakes and formats your code.

On this page

The editor knows JavaScript and TypeScript. It reads your Snippet as you type, with the same TypeScript that checks a TypeScript Snippet, and it works with no connection.

Suggestions

As you type a name, or after a dot, a list of names that fit appears under the cursor. The pane beside it says what the picked name is: its type, and its documentation when it has some.

After word.rep, the list offers repeat, replace and replaceAll; the pane explains repeat.
  • Press ↑ and ↓ to pick a name, Enter to put it in, and Esc to close the list.
  • Press ⌃Space or Ctrl+Space to open the list when it is not showing.
  • After import … from ", the list offers your installed packages.
  • To stop the list from appearing by itself, turn off Settings → Editor → Suggest while typing. ⌃Space or Ctrl+Space still opens it.

When you type a function call, a box lists what the function takes, and marks the argument you are typing.

Types on hover

Rest the pointer on a name to see its type. This works in JavaScript too: the type is the one TypeScript works out from your code.

Hovering price shows the function’s type; hovering the underlined argument shows why it is wrong.

To turn this off, open Settings → Editor → Show types on hover. In the Timeline, hovering a name shows its value instead, whatever this setting says.

Mistakes

The editor underlines mistakes a moment after you stop typing. Rest the pointer on an underline to read the message.

  • In a TypeScript Snippet, it checks types too, and underlines type errors, as in the picture above.
  • In a JavaScript Snippet, it underlines mistakes in the syntax. TypeScript syntax is one of them.
TypeScript types in a JavaScript Snippet are underlined, and the Run fails. Picking TypeScript fixes it.

A type error does not stop the Run: the code runs, and the console shows what it did. To make a type error stop a TypeScript Run, see My TypeScript did not run because of a type error.

Format Code

Format Code tidies the spacing, line breaks and quotes of the code on screen. Do one of these:

  • Press ⇧⌥F or Shift+Alt+F.
  • Choose Edit → Format Code.
  • Click the Format button in the footer.
The same code before and after Format Code: no semicolons, double quotes, and each item on its own line.
  • JSpark formats with Prettier, built into the app, so it works offline. The first time, it takes a moment to load.
  • The style is no semicolons, double quotes, and lines up to 90 characters. In JSpark+, you can change it: see below.
  • In a web Snippet, it formats the Part you are looking at, and no other.
  • Code that can’t be read, such as a missing bracket, is left as it is. The Format button then says Fix the syntax first.

Format style JSpark+

In JSpark+, Settings → Editor → Format style sets how Format Code writes your code. Format before running uses the same style.

Format style at its defaults: no semicolons, double quotes, spaces inside braces, trailing commas everywhere, and (x) => for one arrow parameter.
  • Semicolons, Single quotes, Spaces inside braces and Indent with tabs are switches.
  • Trailing commas is All, ES5 or None.
  • Parentheses around one arrow parameter is a switch: on writes (x) => x, off writes x => x.
  • Lines wrap at 90 characters, with indents of 2 spaces. To change either, set printWidth or tabWidth in a .prettierrc. A width you set in Settings before version 1.2.0 stays in use, and Format style says so.
  • Once the style is not the default, Back to the default style appears under the options.

A .prettierrc in the Working Folder wins over these settings. JSpark reads it each time you format, so a change to the file applies the next time.

  • The file can be .prettierrc, .prettierrc.json, .prettierrc.yaml or .prettierrc.yml, written in JSON or YAML. A config written in JavaScript is not read.
  • Only the options above are taken from it, plus printWidth (40 to 200) and tabWidth (1 to 8).
  • What the file leaves out is Prettier’s own default, not your setting. So {"singleQuote": true} gives single quotes and semicolons, with lines up to 80 characters.

In JSpark, a .prettierrc is not read. Changing an option away from its default says what JSpark+ adds, and changes nothing. A style you chose in JSpark+ stays in use, and you can put any option back to its default.

Format before running JSpark+

In JSpark+, Settings → Editor → Format before running formats your code each time you press Run or open the Timeline. It does not format while Run as you type runs your code. It is on at first.

Code that can’t be formatted runs as it is. In JSpark, the setting stays off, and Format Code works as above.

Tailwind suggestions JSpark+

In JSpark+, when the Snippet’s style uses Tailwind, the list inside class="…" or className="…" offers Tailwind’s class names. The pane beside it shows the CSS each class makes. In JSpark, there are no Tailwind suggestions, and Tailwind styles still work. See Tailwind CSS.

Vim keys

To edit with Vim’s modes, motions and operators, turn on Settings → Editor → Vim keybindings. Turn it off to go back to the editor’s own keys.

  • The editor starts in normal mode. The mode, such as NORMAL, INSERT or VISUAL LINE, is shown at the start of the footer.
  • The app’s own shortcuts work in every mode, such as ⌘↵ or Ctrl+Enter to run. See Keyboard shortcuts.

Good to know

  • A long line continues on the next row. To keep it on one row and scroll sideways instead, turn off Settings → Editor → Wrap long lines.
  • To draw a faint square grid behind the code, one square per line, turn on Settings → Editor → Grid behind code.
  • Brackets and quotes close themselves as you type the opening one.
  • While the Timeline is open, the editor is read-only.

The pictures show JSpark on a Mac. On Windows, the window buttons are at the top right, the menus are in theMenu button at the left end of the tabs, and shortcuts use Ctrl where a Mac uses ⌘. The rest works the same way.

Esc

Type to search every docs page.

JSpark is downloading

When you open JSpark-Setup.exe, Windows may stop it once, because the installer isn’t code-signed yet. If the file came from jspark.app:

A blue Windows box, “Windows protected your PC”: Microsoft Defender SmartScreen prevented an unrecognised app from starting. Under it, the link More info, and the button Don’t run.

1Click More info.

The same box after More info: Application JSpark-Setup-1.4.0.exe, Publisher Unknown publisher, and the buttons Run anyway and Don’t run.

2Then click Run anyway.

You see this only once: updates install inside the app. More in Install JSpark.