curd
A small terminal code editor written in Rust with crossterm: open a folder as a project, browse it in a file tree with git status colours, keep several files open in tabs, and get colours, errors, suggestions, hover and go-to-definition from language servers. It has undo, search, and markers beside the lines you changed since the last commit.
Package name: curd-editor (curd is taken on crates.io). Command name: curd.
Install
One command, no Rust needed. It downloads the latest release for your system.
Linux and macOS:
|
Windows (PowerShell):
irm https://raw.githubusercontent.com/vikram5258/crud-editor/main/install.ps1 | iex
Then:
Other ways to get it:
- With Rust installed:
cargo install curd-editor - By hand: download a binary from the releases page
Run
Keys
Project and files:
| Key | What it does |
|---|---|
| Ctrl+P or Alt+P | quick open: type part of a file name, Enter opens it, Esc cancels |
| Ctrl+B or Alt+B | show or hide the file tree |
| Alt+E | move between the file tree and the text (Esc also leaves the tree) |
| Arrows, Enter (in the tree) | move; Enter or Right opens a folder or file, Left closes a folder |
| Alt+. and Alt+, | next / previous tab (Ctrl+PageDown / Ctrl+PageUp also work) |
| Alt+1 ... Alt+9 | go to that tab |
| Ctrl+W or Alt+W | close the file in front (asks for a second press if it has unsaved changes) |
| Ctrl+S | save; a file with no name yet asks for one first |
| Ctrl+Q | quit (asks for a second press if any file has unsaved changes) |
Editing:
| Key | What it does |
|---|---|
| Typing, Enter, Tab | insert text, a new line, four spaces |
| Backspace / Delete | delete before / under the cursor (joins lines at a line edge) |
| Arrows, Home, End | move the cursor; the view scrolls in both directions |
| PageUp / PageDown | move one screen up / down |
| Ctrl+Home / Ctrl+End | go to the start / end of the file |
| Ctrl+Z / Ctrl+Y | undo / redo |
| Ctrl+F or Alt+F | search: type to find, Enter or Down for the next match, Up for the one before, Esc to close |
| F3 or Alt+N | next match of the last search |
| Ctrl+Space or Alt+/ | ask the language server for suggestions (they also appear by themselves as you type) |
| Up / Down, Tab, Esc (in the list of suggestions) | pick one, put it in, close the list |
| Alt+K or Ctrl+K | fold / unfold the block on, or around, the cursor line |
| Alt+A | fold every top-level block, or unfold everything |
| Alt+H or F2 | hover: show what the language server knows about the thing under the cursor |
| Alt+G or F12 | go to definition, opening the file it is in if needed |
| Tab after a trigger word | expand a snippet (see below) |
Mouse: click a file or folder in the tree, a tab, or a spot in the text; the wheel scrolls whatever is under the pointer. Because curd listens to the mouse, selecting text to copy with the terminal needs Shift held while dragging (Option on macOS Terminal).
Some terminals keep certain Ctrl keys for themselves (VS Code's terminal takes Ctrl+K, Ctrl+B, Ctrl+P, Ctrl+W and Ctrl+F), which is why most commands also have an Alt or function-key form.
Projects
curd some-folder opens the folder as a project. curd some-file works out the project from the file: its git repository if it is in one, otherwise the folder it sits in. Ctrl+B shows the tree either way.
- File tree: folders first, then files. Folders are read only when you open them, so large projects open instantly. The tree follows the file in front, and is re-read when you save or come back to the terminal window.
- Git status colours, with a letter at the right edge of the tree, the same idea as VS Code:
| Colour | Letter | Meaning |
|---|---|---|
| plain | committed and unchanged | |
| yellow | M |
modified since the last commit, not staged |
| cyan | S |
staged with git add, waiting to be committed |
| green | U |
untracked: a new file git does not know yet |
| red | ! |
merge conflict |
| dim | ignored by .gitignore |
A folder takes the colour of the most pressing change inside it. The current branch is shown under the tree. The status comes from the git command, run in the background so it never holds up typing.
- Change markers beside the text: in a file that git tracks, a bar next to the line numbers shows what is different from the last commit, and it follows every key, saved or not:
| Marker | Meaning |
|---|---|
green ▎ |
a new line |
yellow ▎ |
a changed line |
red ▁ |
lines were removed below this line (▔ at the top of the file: removed above it) |
- Tabs: every open file keeps its own cursor, folds and unsaved changes. The tab bar appears when two or more files are open; a
●marks unsaved changes. - Quick open (Ctrl+P): searches every file git tracks or would track (so not
target/ornode_modules/). Letters can be spread out:wsrsfindsworkspace.rs.
Language servers (LSP)
curd gets colours, errors, warnings, suggestions, hover and go-to-definition from the same language servers VS Code and other editors use. It starts the server for the file's type, if it is installed. One server looks after all the open files of its language in a project, so opening more files does not start more servers:
| Language | Server | Install |
|---|---|---|
| Rust | rust-analyzer |
rustup component add rust-analyzer |
| Python | pyright-langserver |
npm install -g pyright |
| JavaScript / TypeScript | typescript-language-server |
npm install -g typescript typescript-language-server |
| C / C++ | clangd |
your system's clangd package |
| Go | gopls |
go install golang.org/x/tools/gopls@latest |
- Colours: come from two places, as in VS Code. A small built-in scanner colours keywords, strings, comments and numbers the instant a file opens and on every key, with or without a server. The server then says what each piece of code really is (function, type, macro and so on) and its colours are laid over the scanner's a moment later. They are your terminal's own sixteen colours, so they match your terminal theme.
- Underlines: the exact code an error or warning is about is underlined. Unused code is shown faded and deprecated code struck through.
- Suggestions (completion): a list opens under the cursor when you start a word or type
.or::, and narrows as you keep typing. Up and Down pick one, Tab puts it in, Esc closes the list. Enter always starts a new line, so the list never gets in the way of plain typing. Ctrl+Space (or Alt+/) asks for the list by hand. - Lines with a problem get a red
Eor yellowWbeside the line number; move the cursor onto the line to read the message in the status bar. The status bar also shows a count, likeE:1 W:2. - Without a server installed,
curdworks as a plain editor and says so once in the status bar. CURD_LSP=off curd file.rsturns servers off.CURD_LSP="my-server --stdio" curd file.rsuses a different one.
How it works: curd runs the server as a child process and talks to it over stdin/stdout. Edits are sent as small changes (not the whole file), batched while you type, and a background thread reads the answers, so typing never waits on the server.
Code editing
- Line numbers in a column on the left.
- Undo and redo: Ctrl+Z takes back the last step and Ctrl+Y does it again. A step is a word typed in one go, a paste, a snippet or a suggestion. Undoing back to what was saved clears the
[modified]mark. - Search: Ctrl+F (or Alt+F) asks in the status bar and jumps to the first match as you type, with every match on screen shown in reverse. Enter or Down goes to the next match, Up to the one before, wrapping round the file. It ignores case unless you type a capital letter. After Esc, F3 (or Alt+N) repeats the search.
- Save as: Ctrl+S in a file with no name asks for one in the status bar. It never overwrites a file that already exists.
- Folding: lines that start a block have a
-beside their line number. Alt+K (or Ctrl+K) collapses the block into one row, shown asfn main() { ... }with a+; the same key opens it again. Alt+A folds or unfolds everything. Blocks are{ ... }in most languages and indentation in Python. Folding only changes the view, never the file. - Auto-indent: Enter keeps the current indentation and adds a level after
{,(or[(and after:in Python). Typing}on a blank line steps back a level. - Paste: pasted text goes in exactly as copied, without auto-indent.
- Snippets: type a trigger word and press Tab. Which ones exist depends on the file extension:
| Language | Triggers |
|---|---|
Rust (.rs) |
fn main struct enum impl match if for while loop test tests pl |
Python (.py) |
def class if for while main try |
| JavaScript / TypeScript | fn afn if for while log |
| C / C++ | main if for while inc |
Go (.go) |
fn main if for err |
For example, in a .rs file main + Tab becomes:
curd new-file.txt starts an empty document and creates the file on the first save. The bottom row is a status bar with the file name, a [modified] marker and the cursor position.
Test
- Unit tests sit next to the code in a
tests.rsfile per module, such assrc/editor/tests.rs. - End-to-end tests in
tests/e2e.rsstart the realcurdin a pseudo-terminal, send keys and check the screen (Linux/macOS only). - The language-server tests use a small fake server,
tests/fake_lsp.py(needspython3). To also test against the realrust-analyzer:cargo test --test e2e -- --ignored.
Test files are left out of the published crate (see include in Cargo.toml).
CI runs on every push and pull request (.github/workflows/ci.yml):
- the tests on Linux, macOS and Windows, with a JUnit report saved on the run
- clippy, and a check that the crate packages cleanly for crates.io
- coverage, which fails under 90% of lines, with the report saved on the run
- the end-to-end test against the real
rust-analyzer cargo audit, which fails if a dependency has a known security problem- release builds for all five platforms
Pushing a v* tag runs the same checks first and only publishes a release (GitHub binaries with a SHA256SUMS file, then crates.io) if they pass.
Layout
src/main.rs— reads the arguments and starts everything upsrc/workspace.rs— the whole window: tabs, file tree, quick open, routing keys, mouse and language-server messagessrc/tree.rs— the file treesrc/git.rs— git status and branch, read from thegitcommandsrc/finder.rs— quick open and its fuzzy matchingsrc/screen.rs— styled rows of text, and drawing only the rows that changedsrc/terminal.rs— raw mode, alternate screen, mouse and focus reports, screen size (restored on drop)src/document.rs— the text (lines), editing it, opening and saving filessrc/editor.rs— one open file: keys, editing, scrolling, its part of the screen, status barsrc/history.rs— what was typed and deleted, for undo and redosrc/search.rs— finding textsrc/diff.rs— which lines differ from the last commit, for the change markerssrc/folds.rs— finding{ ... }blocks and tracking which are collapsedsrc/snippets.rs— snippet tables per languagesrc/lsp.rs— language server client: starting servers, the wire format, requests and repliessrc/highlight.rs— colours: the built-in scanner, and the server's colours kept per line and moved along as you type
Progress
- Step 1: raw mode, read keys, Ctrl+Q
- Step 2: draw the screen with
~and a welcome message - Step 3: open a file and show it (modular refactor)
- Step 4: cursor movement and vertical scrolling
- Step 5: typing and deleting
- Step 6: save with Ctrl+S, unsaved-changes warning, new files
- Status bar and horizontal scrolling
- Line numbers, code folding, snippets, auto-indent, paste
- LSP: diagnostics, hover, go to definition
- Colours, underlines and other decorations from the language server
- Built-in syntax colouring, so colours never wait for the server
- Projects: file tree, tabs, quick open, git status colours, mouse
- One language server shared by all open files; go to definition across files
- LSP: completion
- Git: changed-line markers beside the text
- PageUp / PageDown, Ctrl+Home / Ctrl+End
- Save as (name a file started without one)
- Search, undo and redo
- Search and replace, search across the project
- Select text with Shift+arrows; copy, cut
- Git: stage and commit from the editor