edlin

package
v0.0.0-...-15f74bb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2026 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package edlin implements the EDLIN line-oriented text editor.

Command summary (all commands are case-insensitive):

[n]        display / go to line n
[n][,m]L   list lines (default: 23 lines from current)
[n]I       insert lines before line n  (end input with a line containing only ".")
A          append lines after current line (end input with ".")
[n][,m]D   delete line(s)
[n][,m]S term   search for term
[n][,m]R   replace (prompts for strings; or inline with Ctrl-Z separator)
W          write file without exiting
E          write file and exit
Q          quit without saving (confirms if there are unsaved changes)
U          undo last change
H          help

Addresses: an integer, . (current line), or $ (last line).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrintHelp

func PrintHelp(w io.Writer)

PrintHelp writes the EDLIN command summary to w. Also called by the H command inside an editing session.

Types

type Editor

type Editor struct {
	// contains filtered or unexported fields
}

Editor holds the EDLIN editing state for a single file.

func New

func New(filename string) (*Editor, error)

New opens filename for editing. If the file does not exist an empty buffer is prepared (new file).

func (*Editor) Lines

func (ed *Editor) Lines() []string

Lines returns a copy of the current buffer (used in tests).

func (*Editor) Run

func (ed *Editor) Run(in io.Reader, out io.Writer) error

Run starts the interactive EDLIN session, reading commands from in and writing output to out.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL