tosh help / tips

Also read the language guide.

Here are some tips on using the editor.

Opening projects

Tip: You can open projects by dragging the file into the browser window.

Make sure your browser is up-to-date, and check you can save before starting work! I recommend using Chrome, although Firefox should work too.

Safari warning: Safari unhelpfully names saved files as Unknown, Unknown-2 and so on, so your Mac won’t recognise them as Scratch files. You have to rename them manually; unfortunately this is a problem with Safari and so there’s no way I can fix this.

Buying the Mac app should fix saving-related issues :-) It also works offline, supports autosave, and can load bigger project files.

Indentation

Select some tosh code and press Tab ⇥ to auto-indent.

Auto-complete

Tosh supports "code completion" or "auto-complete":

You can also press Tab ⇥ to jump between inputs, just like in Scratch!

Playing Projects

I’m using Phosphorus to play projects.

Phosphorus runs Scratch projects very fast, and integrates into tosh very well. Unfortunately, it works slightly differently to how Scratch does.

The following things are not supported:

Turbo mode

Shift-click the green flag for turbo mode. This is the same as both Scratch and Phosphorus.

Renaming variables

To rename a variable, use find/replace, like in a normal programming language!

Renaming a variable does not automatically update all the places it’s used, like Scratch does, because it wouldn’t work if you currently had a syntax error.

Find/replace

Find:

Replace:

  1. Shift-Ctrl-F / Cmd-Option-F ⌥⌘F, then input what to replace
  2. Enter , then input what to replace it with
  3. Enter again, then click “All”

Keyboard shortcuts

  1. Press Ctrl-Return / Cmd-Return ⌘⏎ to compile and run your project.
  2. Test out your project!
  3. Press Escape to return to the scripts editor, to continue writing your program.

Vim mode

Yes, tosh supports vim keybindings! Open your browser’s JavaScript console, and execute the following:

App.settings.keyMap.assign('vim');

Now you can use most vim-like keybindings; see the CodeMirror docs.

To change it back, just run:

App.settings.keyMap.assign('default');

Remember, when the project is focused you can press Esc to get back to the code editor.

For the Mac app, instead run the following commands in Terminal:

defaults write org.tjvr.tosh.Tosh toshSettings -dict keyMap vim

To change it back:

defaults write org.tjvr.tosh.Tosh toshSettings -dict keyMap default

Emacs mode

See Vim mode above, but use emacs instead of vim.

Hacked blocks

Some Scratch projects use “hacked” blocks: these are special blocks made by editing the JSON files by hand, which cannot be made using the normal Scratch editor.

There are currently no plans to support these. Sorry!