MLE(1)

πŸ“¦
version 1.8.1 Β· 3 versions
, in alpine 3.24, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– MLE β€” the flexible terminal-based text editor πŸ’–

okay bestie, sit down, because this is mle(1) from the General Commands Manual, and she is a whole vibe ✨


🌸 NAME 🌸

mle β€” flexible terminal-based text editor 🫢


✨ SYNOPSIS ✨

mle [-abceHhiKklMmNnpSstuvwxyz] [file[:line]] ...

πŸ¦‹ DESCRIPTION πŸ¦‹

mle is a small, flexible, terminal-based text editor written in C. It runs on Linux, Windows (Cygwin or WSL), FreeBSD, macOS, and more. no cap, she's everywhere πŸ’…

πŸŽ€ Basic usage πŸŽ€

$ mle             # Open blank buffer
$ mle one.c       # Edit one.c
$ mle one.c:100   # Edit one.c at line 100
$ mle one.c two.c # Edit one.c and two.c
$ mle -h          # Show command line help

The default key bindings are intuitive. Input text as normal, use directional keys to move around, use Ctrl-S to save, Ctrl-O to open, Ctrl-X to exit. that's it, that's the whole tutorial, you're already a main character πŸ‘‘

Press F2 for full help. literally press it. it's right there. πŸ”₯

🌈 Options 🌈

  • -h β€” Show help πŸ™‹
  • -a ⟨1|0⟩ β€” Enable/disable tab to space (default: 1)
  • -b ⟨1|0⟩ β€” Enable/disable highlight bracket pairs (default: 1)
  • -c column β€” Color column (default: -1, disabled)
  • -e ⟨1|0⟩ β€” Enable/disable mouse support (default: 0)
  • -H ⟨1|0⟩ β€” Enable/disable headless mode (default: 1 if no tty, else 0)
  • -i ⟨1|0⟩ β€” Enable/disable auto indent (default: 0)
  • -K kdef β€” Make a kmap definition (use with -k).
    • kdef is formatted as <name>,<default_cmd>,<allow_fallthru>, where name is the name of the kmap, default_cmd is the default command handler (can be empty), and allow_fallthru is a 0 or 1 specifying whether unhandled key input should be forwarded to the previous kmap on the stack or not. πŸ’«
  • -k kbind β€” Add key binding to current kmap definition (use after -K).
    • kbind is formatted as <cmd>,<key>,<param>, where cmd is a command name, key is a key name, and param is a static parameter passed to the command (can be empty).
  • -l ltype β€” Set linenum type (default: 0, absolute).
    • ltype can be 0 (absolute), 1 (relative), or 2 (both)
  • -M macro β€” Add a macro.
    • macro is formatted as <name> <key1> <key2> ... <keyN>, where name is the name of the macro, and keyN are space-separated key names.
  • -m key β€” Set macro toggle key (default: M-r). key is a key name.
  • -N β€” Skip reading of rc file πŸ™ˆ
  • -n kmap β€” Set init kmap (default: mle_normal). kmap is a kmap name.
  • -p macro β€” Set startup macro. macro is a macro name.
  • -S syndef β€” Make a syntax definition (use with -s).
    • syndef is formatted as <name>,<path_pattern>,<tab_width>,<tab_to_space>, where name is a syntax name, path_pattern is a path matching regex (PCRE), tab_width is the default tab width, tab_to_space is a 0 or 1 specifying whether to convert tabs to spaces or not.
  • -s synrule β€” Add syntax rule to current syntax definition (use after -S).
    • synrule is formatted as <start>,<end>,<fg>,<bg>, where start and end are text matching regexes (PCRE), and fg and bg are attributes to apply to matching text.
    • If both start and end are supplied, the rule applies to all text matched in between the regexes, potentially spanning multiple lines. If only start is specified, the rule applies to text matched by the regex on a single line.
    • Attributes for fg and bg are as follows:
      • 0 β€” default
      • 1 β€” black
      • 2 β€” red
      • 4 β€” yellow
      • 5 β€” blue
      • 6 β€” magenta
      • 7 β€” cyan
      • 8 β€” white
      • 256 β€” bold
      • 512 β€” underline
      • 1024 β€” reverse
      • 2048 β€” italic
  • -t size β€” Set tab size (default: 4)
  • -u ⟨1|0⟩ β€” Enable/disable coarse undo/redo (default: 0)
  • -v β€” Print version and exit ⭐
  • -w ⟨1|0⟩ β€” Enable/disable soft word wrap (default: 0)
  • -x uscript β€” Run a Lua user script (experimental) 🧚
  • -y syntax β€” Set override syntax for files opened at start up. If '-' is specified, use the built-in generic syntax. syntax is any syntax name.
  • -z ⟨1|0⟩ β€” Enable/disable trimmed paste (default: 1)

πŸ’œ KEY NAMES πŸ’œ

Key names for -k, -M, and -m are formatted as <key> or <mod>-<key>.

key is any character or one of the following: space, tab, enter, backspace, comma, up, down, left, right, insert, delete, home, end, pgup, pgdn, backtab, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12.

mod is one of

  • S β€” Shift
  • M β€” Alt (Meta)
  • MS β€” Alt-Shift
  • C β€” Ctrl
  • CS β€” Ctrl-Shift
  • CM β€” Ctrl-Alt
  • CMS β€” Ctrl-Alt-Shift
⚠️ Not all key names are valid or supported by all terminals. Run with -Qk to display key names for given input.

🌟 ADVANCED USAGE 🌟

Below are some advanced things you can do with mle. buckle up bestie, this is where it gets good πŸ’…

πŸ“ rc file πŸ“

To customize the editor, make an rc file named ~/.mlerc or /etc/mlerc. The contents of the rc file are any number of cli options separated by newlines. Lines that begin with a semi-colon are interpreted as comments. πŸ“

If the rc file is executable, mle executes it and interprets the resulting stdout as described above. For example, consider the following snippet from an executable ~/.mlerc bash(1) script:

...
# Define 'test' kmap
echo '-Ktest,,1'

# M-q: replace grep with git grep if `.git` exists
if [ -d ".git" ]; then
  echo '-kcmd_grep,M-q,git grep --color=never -P -i -I -n %s 2>/dev/null'
fi

# Set default kmap
echo '-n test'
...

This overrides the built-in grep command with git grep if .git exists in the current working directory. iconic behaviour honestly πŸ‘‘

πŸ¦‹ Shell command integration πŸ¦‹

The following programs will enable or enhance certain features of mle if they exist in PATH.

Arbitrary shell commands can also be run via cmd_shell (M-e by default). If any text is selected, it is sent to stdin of the command. Any resulting stdout is inserted into the text buffer. ✨

🌈 Headless mode 🌈

mle provides support for non-interactive editing which may be useful for using the editor as a regular command line tool. In headless mode, mle reads stdin into a buffer, applies a startup macro if specified, and then writes the buffer contents to stdout. For example:

$ echo -n hello | mle -M 'test C-e space w o r l d enter' -p test
hello world

If stdin is a pipe, mle goes into headless mode automatically. Headless mode can be explicitly enabled or disabled with the -H option.

If stdin is a pipe and headless mode is disabled via -H0, mle reads stdin into a new buffer and then runs as normal in interactive mode.

🧚 Scripting (experimental) 🧚

mle is extensible via the Lua programming language. Scripts are loaded via the -x cli option. Commands registered by scripts can be mapped to keys as normal via -k. See https://github.com/adsr/mle for more info.

πŸ’€ "experimental" means experimental, bestie β€” it's literally labelled that way in the original, so don't come for me.

πŸ’– ACKNOWLEDGEMENTS πŸ’–

mle makes extensive use of the following libraries.

  • uthash β€” for hash maps and linked lists
  • termbox2 β€” for TUI
  • PCRE2 β€” for syntax highlighting and search

and that's the whole page, you ate it, no crumbs πŸŽ€

This one ships from Debian and it's dated March 1, 2023 β€” so if you're reading this in the future, hi, hope the vibes held up πŸ’–