• Stars
    star
    788
  • Rank 57,762 (Top 2 %)
  • Language
    C
  • License
    Apache License 2.0
  • Created almost 10 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

flexible terminal-based text editor (C)

mle

mle is a small, flexible, terminal-based text editor written in C.

Runs on Linux, Windows (Cygwin or WSL), FreeBSD, macOS, and more.

Build Status

Packaging status

Demos

asciicast

Aims

  • Keep codebase small and hackable
  • Minimize build-time and run-time dependencies
  • Make extensible and configurable
  • Favor simplicity over portability
  • Use shell commands to enhance functionality (e.g., grep, tree)

Features

  • Small codebase (~10k sloc)
  • Full UTF-8 support
  • Syntax highlighting
  • Stackable key maps (modes)
  • Extensible via Lua
  • Scriptable rc file
  • Key macros
  • Multiple splittable windows
  • Regex search and replace
  • Large file support
  • Incremental search
  • Linear undo and redo
  • Multiple cursors
  • Auto indent
  • Headless mode
  • Navigation via ctags
  • Movement via less
  • Fuzzy file search via fzf
  • File browsing via tree
  • File grep via grep
  • String manip via perl

Building

$ sudo apt install git build-essential libtool automake # or equivalent
$
$ git clone --recursive https://github.com/adsr/mle.git
$ cd mle
$ make mle_vendor=1

To build a completely static binary, try make mle_vendor=1 mle_static=1.

You can also run plain make to link against system libraries instead of vendor/. Note this requires the following packages to be installed:

uthash-dev
liblua5.4-dev
libpcre2-dev

To install to /usr/local/bin:

$ make install

To install to a custom directory, supply prefix, e.g.:

$ make install prefix=/usr # /usr/bin/mle

Installing from a repo

mle may be available to install via your system's package manager.

# apt install mle   # Ubuntu and Debian-based distros
# dnf install mle   # CentOS, RHEL, Fedora-based distros
# pkg install mle   # FreeBSD
# yay -S mle        # Arch (via AUR)
# snap install mle  # all major Linux distros
# nix-env -i mle    # NixOS (via nixpkgs)
# apk add mle       # Alpine
# xbps-install mle  # Void
# brew install mle  # macOS (Homebrew)
# port install mle  # macOS (MacPorts)
# setup-x86.exe -q -P mle # Cygwin

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.

Advanced usage: mlerc

mle is customized via command line options. Run mle -h to view all cli options.

To set default options, 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 ~/.mlerc 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 (tab completion)
  • fzf (fuzzy file search)
  • grep (file grep)
  • less (less integration)
  • perl (perl 1-liners)
  • readtags (ctags integration)
  • tree (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.

Advanced usage: 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.

Advanced usage: Scripting

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 uscript.lua for a simple example.

There is also a wren branch with Wren scripting support. That work is on pause.

Forks

  • eon - mouse support and Notepad-like selections
  • turbo-mle - Turbo Vision port

Acknowledgments

mle makes extensive use of the following libraries.

  • uthash for hash maps and linked lists
  • termbox2 for TUI
  • PCRE2 for syntax highlighting and search

More Repositories

1

phpspy

low-overhead sampling profiler for PHP 7+
C
1,424
star
2

irslackd

self-hosted IRC gateway to Slack
JavaScript
160
star
3

rw.rs

free shell account and web 1.0 hosting @ http://rw.rs/~you
Shell
90
star
4

traer-js

Particle-based physics engine for JavaScript ported from Jeff Traer's Processing library
JavaScript
48
star
5

termbox-php

a termbox wrapper for PHP
C
31
star
6

flow-tools

Automatically exported from code.google.com/p/flow-tools
C
13
star
7

injection-php

libinjection PHP wrapper
C
10
star
8

php-lzo

lzo php extension
C
7
star
9

bashp

output shell commands as parsed JSON trees
C
7
star
10

gobashd

asynchronous queryable bash executor
Go
6
star
11

php4j

call PHP from Java
C
5
star
12

blackfish

MIDI sequencer
C
5
star
13

mlbuf

multiline buffer library
C
5
star
14

pwdrive

GnuPG+GDrive-based password vault
Shell
4
star
15

php-meta-sapi

PHP SAPI written in PHP (via FFI)
PHP
4
star
16

pymachinedrum

Python module for generating Elektron Machinedrum MIDI messages
Python
4
star
17

crawdb

Toy file-based read-write key-value store
C
4
star
18

inkfish

Scriptable MIDI controller and sequencer with plugin support for Elektron Machinedrum, Elektron Monomachine, Novation Launchpad
Java
4
star
19

xselect

a wait-for-stdin wrapper
C
3
star
20

ffmpeg-bodylang

🙊
PHP
3
star
21

elektron-tools

PHP
3
star
22

bpm-parrot

http://atoi.cc/parrot
JavaScript
3
star
23

nes-metroid

mirror of http://www.metroid-database.com/m1/sourcecode.php
3
star
24

syscall-examples

C
3
star
25

dyncall

mirror of dyncall at http://www.dyncall.org
C
3
star
26

nweb

a tiny, safe Web server (static pages only)
C
3
star
27

terminal-editors

Shell
2
star
28

xinject

C
2
star
29

ra-editor

an editor for the Waldorf RackAttack
Python
2
star
30

opl2fun

Arduino
2
star
31

phpkd

Go
2
star
32

fastmac

Shell
2
star
33

dssi

dssi mirror
C
2
star
34

sp

Easy access to file paths in your screen or tmux session
PHP
2
star
35

tree

Mirror of http://mama.indstate.edu/users/ice/tree/
C
2
star
36

mysw

C
2
star
37

QR2Clip

Scan QR code contents directly to clipboard
Java
2
star
38

voidrpc

C
2
star
39

lv2h

C
2
star
40

loghup

log rotation for stdout/stderr
C
2
star
41

pocketjet3plus-linux-setup

2
star
42

adsr

1
star
43

circbuf

a circular buffer cli tool
C
1
star
44

json_decode

cli wrapper for PHP's json_decode function
PHP
1
star
45

xfce4-terminal

personal fork of xfce terminal
C
1
star
46

adsr.github.io

HTML
1
star
47

ladspa-sdk

ladspa-sdk mirror
C
1
star
48

portmidi-php

a portmidi wrapper for PHP
C
1
star
49

rdio_ad_muter

I'm sorry Rdio
JavaScript
1
star
50

dotfiles

personal dotfiles
Shell
1
star
51

marble

C
1
star
52

epollbench

C
1
star
53

screen

GNU Screen
C
1
star
54

dssih

C
1
star
55

pcre-utf-test

C
1
star
56

katzify

Image processing script that automatically generates "Dr. Katz"-style animations from still images
PHP
1
star
57

pingtop2

1
star
58

twitch-avconv

Shell
1
star
59

TemplateRenderer

Minimal PHP template rendering library
PHP
1
star
60

keelpbx

Experimental PBX
Shell
1
star
61

nlua

branch of GNU nano 2.3.2 with hacky-as-shit Lua scriptability
C
1
star
62

wordplay

algorithmic wordplay
Python
1
star
63

ffvumeter

PHP
1
star
64

agar

Agar 1.4.1
C
1
star
65

farmhash

Automatically exported from code.google.com/p/farmhash
C++
1
star
66

a

'a' for abandoned
C
1
star
67

hiredis-php

Redis client for PHP
C
1
star
68

padviz

quick and dirty NES controller visualizer
C
1
star
69

dldyn

dynamically invoke functions in dynamic libraries
C
1
star
70

vte

personal fork of vte
C++
1
star
71

cmudict

fork of cmudict
1
star
72

alsa-lib

alsa-lib mirror
C
1
star
73

aoc2016

http://adventofcode.com/2016
PHP
1
star
74

pchan

Golang-style channels in C
C
1
star
75

railviz

Messing around with transit timetables
Go
1
star
76

mkcstubs

generate function stubs and synchronize function signatures across header and source files
PHP
1
star