micro {dict} file record
micro opens a record in micro, a full-screen editor that does rather more
than edit does. Two things make it the one to use for
programming:
| it highlights SD BASIC | statements, reserved words, intrinsics, strings and comments, from rules SD generates out of the compiler's own tables and ships |
| it has a command bar and a help screen | so everything it can do is reachable and readable without leaving the editor |
It also has multiple files open at once, split windows, a plugin system and
rebindable keys. If you only want to change one line in a record, edit is
less to think about.
SD folds case, so a command may be typed in either case. Commands are shown here in lower case. In the tables, italics mark something you supply and bold marks a word typed as it stands; braces mark an optional part.
The keys below are micro's own, read from the default bindings and the help text inside the executable SD installs — micro 2.0.15. SD installs micro and calls it; it does not implement it, so where a binding differs the editor is right.
Both editors are installed with SD#
You do not install anything. SD's installer checks for both editors and installs whichever is missing, machine-wide, so every account SD creates can reach them.
If that could not happen — an offline machine, or one whose policy blocks the package manager — the verb says so and names the command that installs it, rather than opening nothing and reporting the record unchanged.
The keys#
Ctrl-S saves, Ctrl-Q quits, and Ctrl-G opens the help screen, which is
the answer to everything not on this page.
Ctrl-S |
save |
Ctrl-Q |
close the file — and quit, if it is the last one open |
Ctrl-G |
open and close help |
Ctrl-E |
the command bar — see below |
Alt-G |
show and hide the key hints |
Ctrl-Z · Ctrl-Y |
undo · redo |
Ctrl-X · Ctrl-C · Ctrl-V |
cut · copy · paste |
Ctrl-K · Ctrl-D |
cut the current line · duplicate it |
Ctrl-A |
select all |
Ctrl-F |
find |
Ctrl-N · Ctrl-P |
find next · find previous |
Ctrl-O |
open a file |
Ctrl-T |
open a new tab |
Alt-A · Alt-E |
start · end of line |
Alt-B · Alt-F |
previous · next word |
Function keys work too, for anyone who prefers them: F1 help, F2
save, F3 or F7 find, F4 or F10 quit.
Ctrl-Qcloses the file rather than the editor. With one record open — which is how SD starts it — that is the same thing. With a second file opened by hand it is not, and micro stays up until the last one is closed.
The command bar#
Ctrl-E opens a > prompt at the foot of the screen. It takes micro's own
commands, and the two worth knowing on the first day are:
> help |
the same screen as Ctrl-G |
> help keybindings |
every key, including the ones not listed above |
> set option value |
change a setting for this session |
Saving works#
An earlier multiuser build failed here and it is fixed. Saving used to fail
with Permission denied. Save with sudo not supported on Windows unless the
session was elevated, because SD pointed micro's configuration directory at a
folder under C:\Program Files, which micro has to write to and an ordinary
account may not. micro's configuration directory is now per-user — resolved at
start by micro-home.ps1 (~/.micro, or a fallback under local application
data) — so it is always writable. Saving gives no message; it just works.
Highlighting SD BASIC#
SD SHIPS THE RULES AND POINTS micro AT THEM. They are generated from the BASIC compiler's own tables rather than typed by hand, so the list of statements, reserved words and intrinsics is the one the compiler actually accepts.
It works on a record from a bp file and not on other records, and the
reason is worth knowing: micro decides which language a file is by matching its
name, and a record called MY.REPORT tells it nothing. So SD names the
working copy *record*.editing.sdbasic, and that suffix is what micro
recognizes. A record edited out of any other file is plain text.
What SD does around the editor#
The two screen editors are one SD program with two names. The working copy, the save and compile questions, the two permission gates and the refusals are the same for both, and they are set out on SD TCL - The edit Screen Editor.
In short: the record is copied into $hold, micro is run on the copy, and on
the way out SD asks whether to save it and — for a bp record — whether to
compile and catalog it. Both verbs need OS.EXECUTE permission and a real
terminal, and refuse a session driven down a pipe:
:micro bp zzed
micro needs a terminal to draw on, and this session has none.
ed, the line editor, works anywhere.
Both usage errors name the verb you typed:
:micro
No file name specified. Usage: micro {dict} <file> <record>
:micro bp
No record name specified. Usage: micro {dict} <file> <record>
Marks, and how to type one#
A field mark is a line break, so micro handles fields on its own. The other
three have a token you type instead. Every token is ~ and one more
character, and ~ is the only escape character.
~~ |
a value mark |
~` |
a subvalue mark |
~! |
a text mark |
~- |
a literal ~, where one would otherwise be misread |
~, |
a literal ,, where one would otherwise read as a separator |
Marks in a row are separated by a comma — a text mark, a text mark and a
value mark is ~!,~!,~~. Written token against token a run of marks cannot be
read, so SD puts a comma between them. Type the comma yourself when you enter
marks in a row. It is a separator and not data — which is why a literal comma
standing in exactly that position, between two marks, is written ~,.
The conversion is lossless: no record is refused and none is mangled,
whatever it contains. A tilde is written ~- only where the character after
it would make the pair look like a token — another ~, a backtick, a !, a
-, a ,, or a mark. Everywhere else a tilde is left exactly as you wrote it,
so a~b is still a~b and ordinary source reads normally.
The gate — the os switch, off as delivered#
micro needs the account's os switch, the same one as OS.EXECUTE (and
not sh: an account can be refused the shell and still run the editor, or the
reverse). The administrator turns it on with set.os.access os on, after
admin; it is off as delivered, and an account without it is told so when it
types the verb. With it the editor runs at once, and what it can read or write
outside SD is exactly what your Windows user may touch, because they are the same
permissions. A change is seen at the next sign-on. See Operating System Access
in the Getting Started set. The full account of both editors' gate is in
SD TCL - The edit Screen Editor.
Who has these verbs#
Your account has micro, edit and ed. ed is SD's own line editor and
always runs. micro and edit run outside SD, so they are behind the os
switch, off as delivered and turned on by the administrator with
set.os.access os on — see SD TCL - The edit Screen
Editor.
See also#
SD TCL - The edit Screen Editor · SD TCL - The ed Line Editor · SD TCL - Programs and the Catalog.