TextEd is a command-line text editor inspired by the classic Linux editor ed. It provides a simple interface for line-based text manipulation. The editor supports reading and writing files, editing line ranges, regex-based search and replace, and more.
- Line-based editing in command-line interface
- File loading and saving
- Insert, append, delete, join, move, and copy lines
- Search and replace using regular expressions (with optional flags)
- Block formatting of text
- Undo functionality
- Line addressing with absolute, relative, and shorthand notation
Each command follows this general format:
[ADDRESS],[ADDRESS][COMMAND][DESTINATION_ADDRESS] [ARGUMENTS]
For example:
1,5d # delete lines 1 to 5
s/foo/bar/g # substitute all occurrences of 'foo' with 'bar'
Commands can be followed by optional addresses and arguments, depending on their function.
You can specify lines using:
- Line numbers (e.g.,
1,5)
.— current line$— last line,— from first to last line (1,$)
+n— n lines below the current line-n— n lines above the current line
These can be combined for navigation or used as arguments to commands.
| Command | Description |
|---|---|
P |
Toggle visibility of the * prompt indicating command mode. |
h |
Show message for the last error. |
H |
Toggle detailed error messages. |
p |
Print lines. |
n |
Print lines with line numbers. |
r |
Read a file and append its content to memory. |
w |
Write memory content to a file. |
f |
Set or show the current filename. |
a |
Append lines after the addressed line. Ends with a single dot (.). |
i |
Insert lines before the addressed line. |
d |
Delete lines in range. |
c |
Replace lines in range with new input (insert mode). |
j |
Join lines in range into one. |
m |
Move lines to a different position. |
t |
Copy lines to a new position. |
s/REGEX/REPLACEMENT/FLAGS |
Replace text using regex. |
b |
Align text into a block with optional line width. |
u |
Undo the last change. Can be toggled. |
q |
Quit if no unsaved changes. |
Q |
Force quit without saving. |
e |
Replace current buffer with content of a file (warns if unsaved changes). |
E |
Same as e but without warning. |
g— Replace all occurrences on a linei,I— Case-insensitive matchingn— Show line number with output
$ r example.txt # Read file into memory
1,10d # Delete lines 1 to 10
$ w output.txt # Save to output.txt
/Hello/ # Find line containing 'Hello'
s/old/new/g # Replace all 'old' with 'new'
q # Quit
- A simple
?is printed on errors by default. - Use
Hto enable detailed error messages. - Use
hto view the most recent error message.
Adam Řeřicha
Faculty of Mathematics and Physics, Charles University
Inspired by the classic GNU ed editor.