Nadine: A Text Editing Language

Post Reply
User avatar
tekk
Posts: 66
Joined: Fri Apr 19, 2024 5:17 pm

Nadine: A Text Editing Language

Post by tekk »

I've had a line editor kicking around in my head for a long time, trying to put some of it to paper.

Everything (mostly) is through an edit command. An edit command is a selection and an action.

A selection is a set of contiguous lines. There are three kinds of these:
literal: 1~5, 8~10, 30~59 (select lines 1-5, 8-10, and 30-59.) This also supports relative selections, so 1~5 could also be written as 1~+4 and 30~59 as -18~59 (line 1 and 4 line after it, line 59 and the 18 lines before it.)
regex: all lines matching a regular expression
implicit: if a selection is left out, the last selection is used again.
Selections can also be saved
value=8~10

I'm also considering allowing basic logic on them, something like 1,8,10,90|/regex/ for "these lines plus any line that matches the regex."

Actions are your actual edit commands. All of them will apply to multiselections. I'm also racking my brain trying to think of the most elegant way to handle macros.

i (insert): Insert before selection(s). Go into insert mode.
a (after): Insert after selection(s). Go into insert mode.

c (change): Delete the selection(s). Go into insert mode.
d (delete): Delete the selection(s).

k (kill): Kill(cut) the selection(s). I'm trying to figure out what this means with multi-selections.
x (xerox): Xerox(copy) the selection(s). I'm trying to figure out what this means with multi-selections.

p (paste): Paste before selection(s).
P (paste): Paste after selection(s).
s /before/after/ (substitute): Apply substitution regex to selection(s).
m [move command] (move): Move the selection(s) to the place specified by the move command. The move command is either a single relative motion (-4, +3, etc.) or one relative motion per selection.
r[name][commands](record): Create a named macro which is the composition of commands.
p[name] (play): Execute the macro name on the selection.

Selections and commands are separated by a ":".

A thought on selection: selections are stores as references to the lines not the line numbers, which should make it so that things work as expected:
3~7:m+4
s/title/Title/
will move lines 3-7 down (becoming lines 7-11) and replace "title" with "Title" on lines 7-11. Without this macros wouldn't work very well.


Should macros be able to make selections? That'd make sense but I can't think of a good syntax for it.
Post Reply