xi - a (too) simple text editor
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
samhunter e16afb822f
Development Update
4 months ago
lib Bookmark names restricted to [\^\$a-zA-Z0-9]. Pseudo-bookmarks '^'/bof '$'/eof added. 4 months ago
Makefile Makefile made slightly "smarter"... 4 months ago
README.md Development Update 4 months ago
_xi.slo 'H'elp added. Maybe a way to have multiple buffers as well? 4 months ago
dot-xi.slo Parameter name changed. 4 months ago
xi-hl.png Basic syntax highlighting added. 4 months ago
xi-solaris.png Screenshot changed 4 months ago
xi.png Screenshot updated. 4 months ago
xi.slo Pseudo-bookmark "." (dot/current line) added. 4 months ago

README.md

xi text editor

a (too) simple text editor

Screenshot of xi on Solaris console

What's that

A line-oriented editor pretending to be a full screen visual one. Written in Slope.

Caveat emptor

To make it absolutely clear:

  • It's not a "product", just a bored programmer mucking around;
  • Even if you believe me, when I call it a text-editor - no backup, no sympathy;
  • What happens at ":" is between you and your interpreter - don't complain about breaking anything that way.

Name

Mostly because pico, nano, and micro were already taken. 'milli' was the next, Millie played Eleven, Roman numbers for eleven are XI... Named in the best tradition of "six" (vi) and "sixteen" (xvi) as well...

Command mode keys

  • j/Down - move down one line
  • k/Up - move up one line
  • g - move to the first line
  • G - move to the last line
  • < - move to top of the page
  • > - move to bottom of the page
  • m{char} - set bookmark {char} at the current line
  • '{char} - jump to bookmark {char}
    • besides the already set bookmarks pseudo-bookmark "^" (begin-of-file) and "$" (end-of-file) can be specified as jump destinations
  • d - delete current line
  • y - yank current line
  • "{char}y - yank current line into a {char} named buffer
  • p/P - paste the recently deleted/yanked line below/above the current
  • "{char}p/"{char}P - paste the {char} named buffer below/above the current
  • o/O - open line below/above the current one
  • Enter - in/out of the line edit mode
  • w - write file (prompts for the filename)
  • Q/Ctrl-C - leave without saving the changes
  • X/Ctrl-D - leave with saving the changes
  • : - command-line (similar to ex-mode in vi, risky, can break your editing session if used carelessly)
  • ! - shell-out - start external program and append its output below the current line
  • \ - toggle options
    • \s - toggle syntax highlighting on/off
    • \r - toggle ruler on/off
    • \r - toggle line numbering on/off

Line edit keys

  • Ctrl-A - begin of the line
  • Ctrl-F - one character forward
  • Ctrl-B - one character backwards
  • Ctrl-E - end of the line
  • Ctrl-K - delete from cursor to the end of the line
  • Ctrl-U - delete from beginning of the line to the cursor
  • Ctrl-L - delete the whole line
  • Ctrl-D - delete a character
  • Enter - leave line edit mode

See also line-edit documentation.

Profile file

Yes, there can be one, ~/.xi.slo, but so far it's more a way to off-load some of my experiments (and potential bloat nobody else cares about) than actual configuration file. If you screw up anything in the profile file it will blow in your face. You have been warned.

; auto-scroll - activate with :(auto-scroll)<Enter>
(define auto-scroll
  (lambda ()
    (set! screen-line last-row)
    (set! dot last-row)
    (for () ((< dot (length buf)))
      (begin
        (go-down)
        (redisplay)
        (draw-status)
        (sleep 1000)))))

; Z - insert formatted date
(set! custom-key-bindings
  (assoc custom-key-bindings
    (string->rune "Z")
    '(begin
       (insert-line-at-dot (date "%w %D %f %Y %H:%I:%S %A %Z"))
       (redisplay))))

(set! syntax []) ; clear syntax
(set! syntax (assoc syntax `^#+ *(.*)$` "\27[31;2m$1\27[0m")) ; md header
(set! syntax (assoc syntax `\*([^\*]+)\*` "\27[1m$1\27[0m"))  ; md bold
(set! syntax (assoc syntax `__([^\*]+)__` "\27[4m$1\27[0m"))  ; md underline
(set! syntax (assoc syntax `_([^\*]+)_` "\27[3m$1\27[0m"))    ; md italic
(set! syntax (assoc syntax `~~([^\*]+)~~` 
   "\27[40;30;1m\27[9m$1\27[0m"))                             ; md strike-through

Common Options To Set

In addition to custom key bindings or custom syntax highlighting, as described above, there are a few common toggles/values that can be made to tailor the visual/editing experience. These can all be set in your profile file.

  • line-numbers?, setting to #t will turn on line numbering
    • (set! line-numbers? #t)
  • syntax-on?, setting to #t will toggle syntax highlighting on (but will only highlight if you have a syntax set up for the given filetype)
    • (set! syntax-on? #t)
  • help-intro?, setting to #f will disable the help screen appearing when starting the editor without a file parameter.
    • (set! help-intro? #f)
  • replace-tabs?, setting to #t will cause all tabs in the file being opened to be replaced with spaces
    • (set! replace-tabs? #t)
  • tab-width, sets the tab with to the given number. Must be a positive integer
    • (set! tab-width 6)
  • use-ruler?, setting to #f will disable the on-screen ruler
    • (set! use-ruler? #f)
  • ruler-style, is a string value that should only contain non-printing characters generally representing an escape code sequence supported by your terminal
    • (set! ruler-style "\033[49;32;1m")

Ideas

  • Multi-level undo
    • So far all deleted lines end up on a "paste stack" and can be pasted back from there.
  • Multiple buffers ("open files")
  • Quick navigation shortcuts (half-page up/down, begin/end of the file etc)
  • Search
  • Replace - for now via Slope macros, but getting there...
  • Slope integration, withing and beneath the editing buffer
  • Modular extendability (that's sounds like world domination plans, isn't it?)
    • Probably a lot of utility functions to make writing buffer/viewer interaction scripting easier
    • A way to define custom key bindings
  • It could use a continuous append mode (thinking about it)
  • Better syntax highlighting
  • Much better documentation
  • Maybe, just maybe - at some point - panes/windows (this one doesn't have any priority)

Syntax highlighting

Bugs

Plenty, I am sure.

  • Scrolling is weird

proudly typed in xi, lol