A .NET 10 implementation of an ed-style line editor.
The repository contains a reusable editor core, a console application that exposes the ed command, and a test suite that exercises the editor API, concrete abstractions, and CLI behavior.
Ed/- core editor libraryEd.Cli/- console host that publishes a self-containededexecutableEd.Tests/- automated tests built withTUnitandFsCheckLOG.md- running development log for the project history
The workspace currently contains the individual project files rather than a checked-in solution file.
The Ed project contains the main editing engine:
EdEditor- in-memory buffer management and command executionEdFileSystem- concrete filesystem abstractionEdShell- concrete shell abstraction backed bypwsh.exeIEdRegexEngine- injectable regex abstraction used by search and substitution flowsDotNetEdRegexEngine- default regex implementation backed by.NETregular expressions- supporting models and enums for line ranges, print modes, write modes, search direction, and substitution options
The Ed.Cli project is the command-line host.
It:
- creates an
EdEditorinstance with the concrete filesystem, shell, and regex implementations - accepts an optional file path argument
- reads commands from standard input
- supports multiline text entry for
a,i, andc - writes normal command output to standard output
- writes
?style failures to standard error - toggles prompt and verbose error behavior through the editor commands
By default, the project is configured to publish a self-contained single-file Windows executable. A build and publish alias named ed.exe is also created.
The test project covers:
- editor API behavior
- command parsing and address handling
- filesystem and shell implementations
- integration between
EdEditor,EdFileSystem, andEdShell - end-to-end CLI execution through the built
ed.exe
The current suite contains 214 passing tests and 2 skipped tests.
The current implementation supports a substantial subset of classic ed behavior, including:
- text input commands:
a,i,c - printing commands:
p,n, empty command, addressed print,,p,,l - buffer mutation commands:
d,j,m,t,u,k - file commands:
e,E,r,w,W,f - shell integration:
!,r !,w ! - search and substitution:
/.../,?...?,s/.../.../, previous-pattern reuse, occurrence flags, global replacement - global commands:
g/.../d,g/.../p,g/.../n,g/.../s/.../.../, plusvvariants - state and utility commands:
=,P,H,h,z,q,q!,Q
Address parsing includes support for:
- explicit line numbers
.and$%- marks via
'x - relative offsets with
+and- - search-based addresses
- range separators
,and;
Regex support is implemented through the injectable IEdRegexEngine abstraction.
The default CLI wiring uses DotNetEdRegexEngine, so the current behavior still follows .NET regular expressions rather than canonical UNIX ed regex semantics.
This repository aims at an ed-style editor and currently implements the subset described above. It is not yet documented as a fully conformant UNIX ed replacement.
The shell implementation currently assumes pwsh.exe is available.
Build the core library:
dotnet build .\Ed\Ed.csprojBuild the CLI:
dotnet build .\Ed.Cli\Ed.Cli.csprojBuild the tests:
dotnet build .\Ed.Tests\Ed.Tests.csprojRun the editor from the project:
dotnet run --project .\Ed.Cli\Ed.Cli.csprojOpen a file immediately:
dotnet run --project .\Ed.Cli\Ed.Cli.csproj -- .\notes.txtAfter a debug build, the aliased executable is available at:
Ed.Cli\bin\Debug\net10.0\win-x64\ed.exe
Publish the Windows single-file executable:
dotnet publish .\Ed.Cli\Ed.Cli.csproj -c Release -o .\artifacts\edPublished output includes:
artifacts\ed\ed.exe
The repository uses Microsoft.Testing.Platform through TUnit.
Visual Studio Test Explorer works with the current test project setup.
A plain dotnet test invocation on the .NET 10 SDK requires opting into the newer Microsoft.Testing.Platform test experience. If you do not have that configured, build the test project and run tests from Visual Studio.
a
hello
world
.
1,2p
w notes.txt
q
- external environment access is abstracted behind
IEdFileSystem,IEdShell, andIEdRegexEngine - the CLI host is intentionally thin and delegates editor behavior to
EdEditor - the development history is tracked in
LOG.md