MLE(1)
π 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:1if no tty, else0)-i β¨1|0β©β Enable/disable auto indent (default:0)-K kdefβ Make a kmap definition (use with-k).kdefis 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 a0or1specifying 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).kbindis 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).ltypecan be0(absolute),1(relative), or2(both)
-M macroβ Add a macro.macrois 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).syndefis 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 a0or1specifying whether to convert tabs to spaces or not.
-s synruleβ Add syntax rule to current syntax definition (use after-S).synruleis 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β default1β black2β red4β yellow5β blue6β magenta7β cyan8β white256β bold512β underline1024β reverse2048β 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β ShiftMβ Alt (Meta)MSβ Alt-ShiftCβ CtrlCSβ Ctrl-ShiftCMβ Ctrl-AltCMSβ 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.
bash(1)β file tab completionfzf(1)β fuzzy file searchgrep(1)β file grepless(1)β less integrationperl(1)β perl 1-linersreadtags(1)β ctags integrationtree(1)β file browsing
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 liststermbox2β for TUIPCRE2β 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 π
π¦ where this page comes from
- alpine 3.24: mle-doc 1.8.1-r0 Β· Apache-2.0
- debian trixie: mle 1.7.2-1 Β· Apache
- fedora 43: mle 1.7.2-8.fc43 Β· Apache-2.0
- fedora 44: mle 1.7.2-9.fc44 Β· Apache-2.0
- nixos 26.05: mle 1.8.1
- nixpkgs unstable: mle 1.8.1
- ubuntu noble: mle 1.7.2-1 Β· Apache
- ubuntu questing: mle 1.7.2-1
- ubuntu resolute: mle 1.7.2-1build1 Β· Apache
- ubuntu stonking: mle 1.8.1-1 Β· Apache
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms