Skip to content
Velle Sinclair edited this page Aug 13, 2026 · 3 revisions

Editor

syn-edit is SynapseOS's text editor. It is one modal engine behind three front ends — a terminal editor, a graphical window, and a scripting mode with no terminal at all — so the same keystroke means the same thing whichever one you are using.

Front-end Command
Terminal editor syn-edit file.txt (the default), or syn-edit tui file.txt
The window Editor in the start menu, or syn-edit gui file.txt
No terminal at all syn-edit run -k KEYS file, syn-edit ex -c CMD file

It depends on nothing but libc.


It is modal

Press i to start typing, Escape to stop, :w to write and :q to quit — vim's arrangement, because it is the one a text editor on a Unix system is expected to have and the one the scripting mode needs in order to be a scripting mode at all.

If you have never used a modal editor: the keys do different things depending on which mode you are in. In normal mode d deletes and i starts inserting; in insert mode they type a d and an i. Escape always takes you back to normal mode, and :q! always leaves without saving.

Syntax highlighting

The language is guessed from the file, and --lang NAME forces it.

syn-edit langs                    # every language that is highlighted
syn-edit highlight main.c         # the spans it found, without opening anything

Editing without a terminal

This is the part worth knowing about even if you use another editor. run applies a key sequence to a file and prints the result; ex does the same with ex commands only. Nothing is written unless you ask with -w.

syn-edit run -k 'ggdG' notes.md              # delete every line, print the result
syn-edit run -k 'ciwfoo<Esc>' file.c         # change a word
syn-edit ex  -c '%s/foo/bar/g' -w *.c        # substitute, and write it back
syn-edit run -k 'gg' --status file.c         # cursor, mode and message as records

Keys use vim notation, with <Esc>, <CR>, <Tab>, <BS>, <C-r> and the arrow keys spelled inside angle brackets; a literal < is <lt>.

This is how the editor's own test suite drives it, which is the reason it exists and the reason to trust it: the keys the window sends and the keys a script sends go through one engine, so they cannot come to mean different things.

Patterns

Patterns are POSIX basic regular expressions — the closest thing in libc to vim's default. \( \) group, \| alternates, \+ and \? repeat, and \< \> anchor to word boundaries. A pattern starting with \v is read as an extended regular expression instead, which is what vim's very-magic mode is.

syn-edit ex -c '%s/\<log\>/trace/g' -w app.c      # whole word
syn-edit ex -c '%s/\v(foo|bar)/baz/g'  -w app.c   # very-magic alternation

In the window

The window is the same engine with a mouse: a scrollbar you can drag, click-and-drag to select, Shift+arrows to extend a selection, and a right-click menu. Scrolling moves the caret first and the view second — a modal editor whose view can drift away from its cursor is a modal editor that types in the wrong place.

Settings

syn-edit config list              # every setting and its value
syn-edit config set tabwidth 4
syn-edit config reset
syn-edit about                    # version, licence, and what works on this machine

For front-ends

serve runs the engine on stdin/stdout — it is what the window drives — and --rec prints the machine-readable records a front-end parses.

Every field of --rec output is percent-encoded, including the ones that look like plain words. A line of source code can contain a tab and a file name can contain any byte at all. Decode for display only.

Exit status: 0 success, 1 failure, 2 a usage problem.

See also

Commands · Files · Settings · Development Notes

Clone this wiki locally