Editor Verbs
OQL has a built-in document editor model. An editor document is a plain OqlValue object — open a file into a variable, manipulate it with editor verbs, save it back. No sessions, no WebSockets, no special runtime state.
Document types
| Type | Model | Use for |
|---|---|---|
EDITOR TEXT OPEN | Flat lines, line/col operations | Plain text files (.txt, .md, .csv) |
EDITOR CODE OPEN | Flat lines, line/col operations, language detection | Source files (.js, .py, .rs, .oql, .html, .css, .sql…) |
The language is auto-detected from the file extension and stored in the lang field of the document object. Rich text (.rtf) with full layout, typography, and export to PDF/DOCX/PPTX is a separate planned verb set.
Document object structure
All line and column numbers are 1-based. The document is immutable — every verb returns a new document object. Mutate with SET ?doc to update the variable.
Quick reference
| Verb | Key modifiers / Returns |
|---|---|
EDITOR TEXT OPEN "path" | Open or create a text file → document object |
EDITOR CODE OPEN "path" | Open or create a code file, auto-detect language → document object |
EDITOR READ ?doc | → full content as a single string |
EDITOR SAVE ?doc | INTO "/root/path" — saves to original path or specified path. → document object |
EDITOR INSERT AFTER ?doc | WITH "content" AT "line" — insert after line n. → document object |
EDITOR INSERT BEFORE ?doc | WITH "content" AT "line" — insert before line n. → document object |
EDITOR REPLACE LINE ?doc | AT "line" WITH "content" — replace entire line. → document object |
EDITOR REPLACE RANGE ?doc | FROM "line" TO "line" AT "col" USING "col" WITH "content" — replace col range. → document object |
EDITOR ERASE ?doc | AT "line" — remove line n entirely. → document object |
EDITOR GOTO ?doc | AT "line" USING "col" — move cursor. → document object |
EDITOR SELECT ?doc | FROM "line" TO "line" AT "col" USING "col" — set selection. → document object |
EDITOR FIND ?doc | WITH "pattern" — case-insensitive substring search. → array of {line, col, text} |
EDITOR COPY ?doc | Copy selection or current line to clipboard[0]. → document object |
EDITOR CUT ?doc | Copy and remove selection or current line. → document object |
EDITOR PASTE ?doc | AT "line" — insert clipboard[0] after line n. → document object |
EDITOR CLIPBOARD LIST ?doc | → array of clipboard strings (max 50) |
EDITOR UNDO ?doc | → document object (undo stack coming soon) |
EDITOR REDO ?doc | → document object (redo stack coming soon) |
Open and read
Insert, replace, erase
Find
Returns an array of {line, col, text} objects — one per match occurrence. Case-insensitive.
Copy, cut, paste
Insert before
Replace range (col-level)
Replace a character range within a line. FROM and TO are line numbers, AT is start column, USING is end column.
Goto and select
EDITOR GOTO moves the cursor. EDITOR SELECT sets a selection range used by COPY and CUT.
Cut
Save to a different path
Code editor with language detection
The language is auto-detected from the file extension and stored in the lang field.
Returns "python". Supported: js → javascript, ts → typescript, py → python, rs → rust, php → php, html → html, css → css, sql → sql, oql → oql, and more.
OQL manipulating its own source
Because the editor state is a plain variable, OQL scripts can read, modify, and save other OQL scripts — meta-programming.