ze - zach's extensible text editor
ze is an extensible text editor that uses GNU Guile as its extension language. It supports running guile code as pre- and post- hooks upon opening a file, opening a directory, or saving a file. It supports highlighting for C, Python, Ruby, PHP, Rust, APL, Swift, and TypeScript.
See the docs for more information.
- Simple and lightweight: Minimal text editor with essential functionality
- Extensible: Uses GNU Guile for scripting and customization
- Syntax highlighting: Supports C, Python, Ruby, PHP, Rust, APL, Swift, and TypeScript
- Hooks system: Pre- and post- hooks for file operations
- Template system: Clone predefined templates for common file types
- Search functionality: Forward search with navigation
- Cross-platform: Works on macOS, Linux, and other Unix-like systems
First, you must install GNU Guile (and its related libraries) on your system. You can follow the official installation instructions or by simply doing:
brew install guileif you are using macOS.
Clone the repository:
git clone git@github.com:zachwick/ze cd zeSet up configuration:
mkdir ~/.ze cp zerc.scm ~/.ze/ cp -R templates ~/.ze/templates
Edit the configuration path: You must edit the path supplied to
scm_c_primitive_loadin themainmethod to match wherever your localzerc.scmconfiguration file is located. A common practice is to copy the example configuration file from the repo into a.zedirectory in your home directory.Build and install:
make install
- Start ze:
ze - Open a file:
ze <filename>
| Key | Action | Description |
|---|---|---|
Ctrl+x | Open a REPL | Opens a Guile Scheme REPL |
| Key | Action | Description |
|---|---|---|
Ctrl+o | Open path | Prompts the user for a path to open in ze |
Ctrl+w | Write to file | Write/Save the current buffer to a file |
Ctrl+t | Clone template | Prompts the user for a template to clone into the current buffer |
| Key | Action | Description |
|---|---|---|
Ctrl+s | Forward search | Prompt for a string to search forward in the document |
Ctrl+n | Next match | Move to the next search match (while searching) |
Ctrl+b | Previous match | Move to the previous search match (while searching) |
ESC | Quit search | Quit searching and return cursor to original position |
Enter | Accept match | Quit searching and leave cursor at current match |
| Key | Action | Description |
|---|---|---|
Ctrl+i | Insert timestamp | Inserts current timestamp at cursor |
Ctrl+d | Delete line | Deletes the entire line that the cursor is currently on |
Ctrl+k | Delete rest of line | Deletes from cursor position to end of line |
Ctrl+h | Delete character | Deletes the character at cursor position |
| Key | Action | Description |
|---|---|---|
Ctrl+p | Move up | Move cursor up one line |
Ctrl+n | Move down | Move cursor down one line |
Ctrl+f | Move forward | Move cursor one column to the right |
Ctrl+b | Move backward | Move cursor one column to the left |
Ctrl+v | Page down | Move cursor to beginning of next page |
Ctrl+g | Page up | Move cursor to beginning of previous page |
ze supports Guile Scheme plugins that are automatically loaded at startup.
- Location: Plugins are
.scmfiles placed in~/.ze/plugins. All non-hidden.scmfiles in that directory are loaded at startup. - Examples:
make installcreates~/.ze/pluginsand copies the example plugins from the repo. - API exposed to Scheme:
set-editor-status(string)— set the status line messagebind-key(key-spec, procedure)— bind a key to a Scheme procedure
- Key specs: Either a single character (e.g.,
"y") or Control chords like"C-y". - Input handling: When a key is pressed, ze checks plugin bindings first. If a bound procedure runs, the built-in handler is skipped for that keypress.
- REPL: Press
Ctrl+xto open a one-line Scheme prompt inside ze to evaluate expressions in the current environment.
Bind a key and set a status message (~/.ze/plugins/hello.scm):
(display"ze: loaded plugin hello.scm") (newline)
(define (ze-hello)
(set-editor-status "Hello from ze plugin!"))
(bind-key "C-y" ze-hello)Override a hook from a plugin (~/.ze/plugins/hooks.scm):
(define (postSaveHook contents)
(string-append "Post-save plugin says: wrote "
(number->string (string-length contents))
" bytes"))See the Hooks section below for the list of available hooks and their return values.
ze supports various Guile hooks for customization:
| Hook Function | Returns | Description |
|---|---|---|
preSaveHook | string | Called prior to writing buffer to file |
postSaveHook | string | Called after writing buffer to file |
preDirOpenHook | string | Called prior to opening a directory in ze |
postDirOpenHook | string | Called after opening a directory in ze |
preFileOpenHook | string | Called prior to opening a file into a buffer |
postFileOpenHook | string | Called after opening a file into a buffer |
To add a new template, you must make changes in three places in ze.c and one place in your zerc.scm configuration file:
Define global variable in
ze.c(around line 90):char*email_template="";
Add template option in
editorCloneTemplatemethod:char*template=editorPrompt("Select Template: (N)otes | (R)eadme | (E)mail", NULL);
Add template handling in the if/else block:
elseif (strcasecmp(template, "e") ==0) { editorSetStatusMessage("LoadEmailtemplate"); templateFile=fopen(email_template, "r"); }
Define template path in
zerc.scm:(defineemail_template '"/Users/zwick/.ze/templates/email")
Read template in main method:
SCMemail_template_scm; email_template_scm=scm_variable_ref(scm_c_lookup("email_template")); email_template=scm_to_locale_string(email_template_scm);
After making these changes, run make install to build and install your new version of ze.
The main configuration file is ~/.ze/zerc.scm. This file contains:
- Template file paths
- Custom Guile functions and hooks
- Editor behavior customization
Contributions are welcome! Please feel free to submit a Pull Request.
ze is copyright 2018, 2019, 2020 zach wick zach@zachwick.com and is licensed under the GNU GPLv3 or later. You can find a copy of the GNU GPLv3 included in the project as the file named LICENSE.txt.
- zach wick - zach@zachwick.com
- Built with GNU Guile for extensibility
- Inspired by simple, efficient text editors such as kilo.