• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

tests/H03-May-2022-1,8281,357

vendor/H14-Feb-2020-3323

.gitignoreH A D14-Feb-202021 43

.gitmodulesH A D14-Feb-2020329 1312

.travis.ymlH A D14-Feb-2020107 65

LICENSEH A D14-Feb-202011.1 KiB203169

MakefileH A D03-May-20221.7 KiB6146

README.mdH A D14-Feb-20205.5 KiB175123

aproc.cH A D14-Feb-20203.7 KiB132101

bline.cH A D14-Feb-20205 KiB158128

buffer.cH A D14-Feb-202057.4 KiB1,8341,465

bview.cH A D14-Feb-202038.5 KiB1,171928

cmd.cH A D14-Feb-202052.4 KiB1,7131,378

cursor.cH A D14-Feb-202013.4 KiB387343

editor.cH A D14-Feb-202088.4 KiB2,3051,920

keys.hH A D14-Feb-20202.7 KiB6968

main.cH A D14-Feb-2020935 3633

mark.cH A D14-Feb-202028.7 KiB807658

mlbuf.hH A D14-Feb-202013.9 KiB360307

mle.1H A D14-Feb-20206.3 KiB282279

mle.hH A D03-May-202223.2 KiB712582

uscript.cH A D14-Feb-202012.2 KiB410324

uscript.incH A D14-Feb-202078.8 KiB2,5972,445

uscript.inc.phpH A D14-Feb-20209.4 KiB242229

uscript.luaH A D14-Feb-2020422 1612

utf8.cH A D14-Feb-20202 KiB8571

util.cH A D14-Feb-202017.6 KiB618464

README.md

1# mle
2
3mle is a small, flexible, terminal-based text editor written in C.
4
5Runs on Linux, Windows (cygwin), FreeBSD, and MacOS.
6
7[![Build Status](https://travis-ci.org/adsr/mle.svg?branch=master)](https://travis-ci.org/adsr/mle)
8
9### Demos
10
11[![asciicast](https://i.imgur.com/PZocaOT.png)](https://asciinema.org/a/162536)
12
13* [Emacs-style jump](https://i.imgur.com/atS11HX.gif)
14* [Large file benchmark](http://i.imgur.com/VGGMmGg.gif)
15* [Older demos](http://imgur.com/a/ZBmmQ)
16
17### Aims
18
19* Keep codebase small and hackable
20* Minimize build-time and run-time dependencies
21* Make extensible and configurable
22* Favor simplicity over portability
23* Use shell commands to enhance functionality (e.g., grep, tree)
24
25### Features
26
27* Small codebase (<10k sloc)
28* Full UTF-8 support
29* Syntax highlighting
30* Stackable key maps (modes)
31* Extensible via [Lua](https://www.lua.org)
32* Scriptable rc file
33* Key macros
34* Multiple splittable windows
35* Regex search and replace
36* Large file support
37* Incremental search
38* Linear undo and redo
39* Multiple cursors
40* Auto indent
41* Headless mode
42* Navigation via [ctags](https://github.com/universal-ctags/ctags)
43* Movement via [less](https://www.gnu.org/software/less/)
44* Fuzzy file search via [fzf](https://github.com/junegunn/fzf)
45* File browsing via [tree](http://mama.indstate.edu/users/ice/tree/)
46* File grep via [grep](https://www.gnu.org/software/grep/)
47* String manip via [perl](https://www.perl.org/)
48
49### Building
50
51    $ sudo apt install git build-essential libtool automake # or equivalent
52    $
53    $ git clone --recursive https://github.com/adsr/mle.git
54    $ cd mle
55    $ make mle_vendor=1
56
57To build a completely static binary, try `make mle_vendor=1 mle_static=1`.
58
59You can also run plain `make` to link against system libraries instead of
60`vendor/`. Note this requires the following packages to be installed:
61
62    uthash-dev
63    liblua5.3-dev
64    libpcre3-dev
65    libtermbox-dev
66
67### Installing
68
69To install to `/usr/local/bin`:
70
71    $ make install
72
73To install to a custom directory, supply `prefix`, e.g.:
74
75    $ make install prefix=/usr # /usr/bin/mle
76
77### Basic usage
78
79    $ mle             # Open blank buffer
80    $ mle one.c       # Edit one.c
81    $ mle one.c:100   # Edit one.c at line 100
82    $ mle one.c two.c # Edit one.c and two.c
83    $ mle -h          # Show command line help
84
85The default key bindings are intuitive. Input text as normal, use directional
86keys to move around, use `Ctrl-S` to save, `Ctrl-O` to open, `Ctrl-X` to exit.
87
88Press `F2` for full help.
89
90### Advanced usage: mlerc
91
92mle is customized via command line options. Run `mle -h` to view all cli
93options.
94
95To set default options, make an rc file named `~/.mlerc` (or `/etc/mlerc`). The
96contents of the rc file are any number of cli options separated by newlines.
97Lines that begin with a semi-colon are interpretted as comments.
98
99If `~/.mlerc` is executable, mle executes it and interprets the resulting stdout
100as described above. For example, consider the following snippet from an
101executable `~/.mlerc` bash(1) script:
102
103    # Define 'test' kmap
104    echo '-Ktest,,1'
105
106    # M-q: replace grep with git grep if `.git` exists
107    if [ -d ".git" ]; then
108      echo '-kcmd_grep,M-q,git grep --color=never -P -i -I -n %s 2>/dev/null'
109    fi
110
111    # Set default kmap
112    echo '-n test'
113
114This overrides the built-in grep command with `git grep` if `.git` exists in
115the current working directory.
116
117### Shell command integration
118
119The following programs will enable or enhance certain features of mle if they
120exist in `PATH`.
121
122* [bash](https://www.gnu.org/software/bash/) (tab completion)
123* [fzf](https://github.com/junegunn/fzf) (fuzzy file search)
124* [grep](https://www.gnu.org/software/grep/) (file grep)
125* [less](https://www.gnu.org/software/less/) (less integration)
126* [perl](https://www.perl.org/) (perl 1-liners)
127* [readtags](https://github.com/universal-ctags/ctags) (ctags integration)
128* [tree](http://mama.indstate.edu/users/ice/tree/) (file browsing)
129
130Arbitrary shell commands can also be run via `cmd_shell` (M-e by default). If
131any text is selected, it is sent to stdin of the command. Any resulting stdout
132is inserted into the text buffer.
133
134### Advanced usage: Headless mode
135
136mle provides support for non-interactive editing which may be useful for using
137the editor as a regular command line tool. In headless mode, mle reads stdin
138into a buffer, applies a startup macro if specified, and then writes the buffer
139contents to stdout. For example:
140
141    $ echo -n hello | mle -M 'test C-e space w o r l d enter' -p test
142    hello world
143
144If stdin is a pipe, mle goes into headless mode automatically. Headless mode can
145be explicitly enabled or disabled with the `-H` option.
146
147If stdin is a pipe and headless mode is disabled via `-H0`, mle reads stdin into
148a new buffer and then runs as normal in interactive mode.
149
150### Advanced usage: Scripting
151
152mle is extensible via the [Lua](https://www.lua.org) programming language.
153Scripts are loaded via the `-x` cli option. Commands registered by scripts can
154be mapped to keys as normal via `-k`. See `uscript.lua` for a simple example.
155
156There is also a `wren` branch with [Wren](http://wren.io) scripting support.
157That work is on pause.
158
159### Known bugs
160
161* Multi-line style rules don't work properly when overlapped/staggered.
162
163### Fork
164
165Also check out [eon](https://github.com/tomas/eon), a fork of mle with some cool
166features.
167
168### Acknowledgments
169
170mle makes extensive use of the following libraries.
171
172* [uthash](https://troydhanson.github.io/uthash) for hash maps and linked lists
173* [termbox](https://github.com/nsf/termbox) for TUI
174* [PCRE](http://www.pcre.org/) for syntax highlighting and search
175