MLE(1) | General Commands Manual | MLE(1) |
mle
— flexible
terminal-based text editor
mle |
[-habcHiKklMmNnpSstvwxyz ]
[file[:line]] ... |
mle
is a small, flexible, terminal-based
text editor written in C. It runs on Linux, Windows (cygwin), FreeBSD, and
MacOS. Visit https://github.com/adsr/mle for more info.
$ 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.
Press `F2` for full help.
-h
-a
⟨1|0⟩-b
⟨1|0⟩-c
column-H
⟨1|0⟩-i
⟨1|0⟩-K
kdefkdef 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
kbindkbind 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
ltypeltype can be 0 (absolute), 1 (relative), or 2 (both)
-M
macromacro is formatted as
`<name> <key1> <key2> ...
<keyN>`
, where name is the name of
the macro, and keyN are space-separated key
names.
-m
key-N
-n
kmap-p
macro-S
syndefsyndef 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
synrulesynrule 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:
-t
size-v
-w
⟨1|0⟩-x
uscript-y
syntax-z
⟨1|0⟩Below are some advanced things you can do with mle.
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 interpretted 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.
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.
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.
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.
mle makes extensive use of the following libraries.
August 1, 2018 | Debian |