Scroll to navigation

MLE(1) General Commands Manual MLE(1)

NAME

mle
flexible terminal-based text editor

SYNOPSIS

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

DESCRIPTION

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.

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.

Press `F2` for full help.

Options

Show help message
⟨1|0⟩
Enable/disable tab_to_space (default: 1)
⟨1|0⟩
Enable/disable highlight bracket pairs (default: 1)
column
Color column (default: -1, disabled)
⟨1|0⟩
Enable/disable headless mode (default: 1 if no tty, else 0)
⟨1|0⟩
Enable/disable auto_indent (default: 0)
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.

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).

ltype
Set linenum type (default: 0, absolute).

ltype can be 0 (absolute), 1 (relative), or 2 (both)

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.

key
Set macro toggle key (default: M-r). key is a key name.
Skip reading of rc file
kmap
Set init kmap (default: mle_normal). kmap is a kmap name.
macro
Set startup macro. macro is a macro name.
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.

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
size
Set tab size (default: 4)
Print version and exit
⟨1|0⟩
Enable/disable soft word wrap (default: 0)
uscript
Run a Lua user script (experimental)
syntax
Set override syntax for files opened at start up. syntax is any syntax name.
⟨1|0⟩
Enable/disable trim_paste (default: 1)

ADVANCED USAGE

Below are some advanced things you can do with mle.

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 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.

Shell command integration

The following programs will enable or enhance certain features of mle if they exist in PATH.
bash(1)
file tab completion
fzf(1)
fuzzy file search
grep(1)
file grep
less(1)
less integration
perl(1)
perl 1-liners
readtags(1)
ctags integration
tree(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.

ACKNOWLEDGEMENTS

mle makes extensive use of the following libraries.
uthash
for hash maps and linked lists
termbox
for TUI
PCRE
for syntax highlighting and search
August 1, 2018 Linux 4.19.0-10-amd64