1MLE(1)                    BSD General Commands Manual                   MLE(1)
2

NAME

4     mle — flexible terminal-based text editor
5

SYNOPSIS

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

DESCRIPTION

10     mle is a small, flexible, terminal-based text editor written in C. It
11     runs on Linux, Windows (cygwin), FreeBSD, and MacOS.  Visit
12     https://github.com/adsr/mle for more info.
13
14   Basic usage
15       $ mle             # Open blank buffer
16       $ mle one.c       # Edit one.c
17       $ mle one.c:100   # Edit one.c at line 100
18       $ mle one.c two.c # Edit one.c and two.c
19       $ mle -h          # Show command line help
20
21     The default key bindings are intuitive. Input text as normal, use direc‐
22     tional keys to move around, use `Ctrl-S` to save, `Ctrl-O` to open,
23     `Ctrl-X` to exit.
24
25     Press `F2` for full help.
26
27   Options
28           -h            Show help message
29
30           -a ⟨1|0⟩      Enable/disable tab_to_space (default: 1)
31
32           -b ⟨1|0⟩      Enable/disable highlight bracket pairs (default: 1)
33
34           -c column     Color column (default: -1, disabled)
35
36           -H ⟨1|0⟩      Enable/disable headless mode (default: 1 if no tty,
37                         else 0)
38
39           -i ⟨1|0⟩      Enable/disable auto_indent (default: 0)
40
41           -K kdef       Make a kmap definition (use with -k).
42
43                         kdef is formatted as
44                         `<name>,<default_cmd>,<allow_fallthru>`, where name
45                         is the name of the kmap, default_cmd is the default
46                         command handler (can be empty), and allow_fallthru is
47                         a 0 or 1 specifying whether unhandled key input
48                         should be forwarded to the previous kmap on the stack
49                         or not.
50
51           -k kbind      Add key binding to current kmap definition (use after
52                         -K).
53
54                         kbind is formatted as `<cmd>,<key>,<param>`, where
55                         cmd is a command name, key is a key name, and param
56                         is a static parameter passed to the command (can be
57                         empty).
58
59           -l ltype      Set linenum type (default: 0, absolute).
60
61                         ltype can be 0 (absolute), 1 (relative), or 2 (both)
62
63           -M macro      Add a macro.
64
65                         macro is formatted as `<name> <key1> <key2> ...
66                         <keyN>`, where name is the name of the macro, and
67                         keyN are space-separated key names.
68
69           -m key        Set macro toggle key (default: M-r).  key is a key
70                         name.
71
72           -N            Skip reading of rc file
73
74           -n kmap       Set init kmap (default: mle_normal).  kmap is a kmap
75                         name.
76
77           -p macro      Set startup macro.  macro is a macro name.
78
79           -S syndef     Make a syntax definition (use with -s).
80
81                         syndef is formatted as
82                         `<name>,<path_pattern>,<tab_width>,<tab_to_space>`,
83                         where name is a syntax name, path_pattern is a path
84                         matching regex (PCRE), tab_width is the default tab
85                         width, tab_to_space is a 0 or 1 specifying whether to
86                         convert tabs to spaces or not.
87
88           -s synrule    Add syntax rule to current syntax definition (use af‐
89                         ter -S).
90
91                         synrule is formatted as `<start>,<end>,<fg>,<bg>`,
92                         where start and end are text matching regexes (PCRE),
93                         and fg and bg are attributes to apply to matching
94                         text.
95
96                         If both start and end are supplied, the rule applies
97                         to all text matched in between the regexes, poten‐
98                         tially spanning multiple lines.  If only start is
99                         specified, the rule applies to text matched by the
100                         regex on a single line.
101
102                         Attributes for fg and bg are as follows:
103
104                               0     default
105
106                               1     black
107
108                               2     red
109
110                               4     yellow
111
112                               5     blue
113
114                               6     magenta
115
116                               7     cyan
117
118                               8     white
119
120                               256   bold
121
122                               512   underline
123
124                               1024  reverse
125
126           -t size       Set tab size (default: 4)
127
128           -v            Print version and exit
129
130           -w ⟨1|0⟩      Enable/disable soft word wrap (default: 0)
131
132           -x uscript    Run a Lua user script (experimental)
133
134           -y syntax     Set override syntax for files opened at start up. If
135                         '-' is specified, use the built-in generic syntax.
136                         syntax is any syntax name.
137
138           -z ⟨1|0⟩      Enable/disable trim_paste (default: 1)
139

ADVANCED USAGE

141     Below are some advanced things you can do with mle.
142
143   rc file
144     To customize the editor, make an rc file named ~/.mlerc or /etc/mlerc.
145     The contents of the rc file are any number of cli options separated by
146     newlines. Lines that begin with a semi-colon are interpretted as com‐
147     ments.
148
149     If the rc file is executable, mle executes it and interprets the result‐
150     ing stdout as described above. For example, consider the following snip‐
151     pet from an executable ~/.mlerc bash(1) script:
152
153       ...
154       # Define 'test' kmap
155       echo '-Ktest,,1'
156
157       # M-q: replace grep with git grep if `.git` exists
158       if [ -d ".git" ]; then
159         echo '-kcmd_grep,M-q,git grep --color=never -P -i -I -n %s 2>/dev/null'
160       fi
161
162       # Set default kmap
163       echo '-n test'
164       ...
165
166     This overrides the built-in grep command with `git grep` if .git exists
167     in the current working directory.
168
169   Shell command integration
170     The following programs will enable or enhance certain features of mle if
171     they exist in PATH.
172
173           bash(1)       file tab completion
174
175           fzf(1)        fuzzy file search
176
177           grep(1)       file grep
178
179           less(1)       less integration
180
181           perl(1)       perl 1-liners
182
183           readtags(1)   ctags integration
184
185           tree(1)       file browsing
186
187     Arbitrary shell commands can also be run via `cmd_shell` (M-e by de‐
188     fault). If any text is selected, it is sent to stdin of the command. Any
189     resulting stdout is inserted into the text buffer.
190
191   Headless mode
192     mle provides support for non-interactive editing which may be useful for
193     using the editor as a regular command line tool. In headless mode, mle
194     reads stdin into a buffer, applies a startup macro if specified, and then
195     writes the buffer contents to stdout. For example:
196
197       $ echo -n hello | mle -M 'test C-e space w o r l d enter' -p test
198       hello world
199
200     If stdin is a pipe, mle goes into headless mode automatically. Headless
201     mode can be explicitly enabled or disabled with the `-H` option.
202
203     If stdin is a pipe and headless mode is disabled via -H0, mle reads stdin
204     into a new buffer and then runs as normal in interactive mode.
205
206   Scripting (experimental)
207     mle is extensible via the Lua programming language. Scripts are loaded
208     via the `-x` cli option. Commands registered by scripts can be mapped to
209     keys as normal via `-k`. See https://github.com/adsr/mle for more info.
210

ACKNOWLEDGEMENTS

212     mle makes extensive use of the following libraries.
213
214           uthash        for hash maps and linked lists
215
216           termbox2      for TUI
217
218           PCRE          for syntax highlighting and search
219
220BSD                             August 1, 2018                             BSD
Impressum