Examples & Walkthroughs
This page demonstrates typical editing workflows using the minimal modred.py implementation.
Example 1 — Create a new file and insert lines
-
Start editing a new file
notes.txt:python3 modred.py notes.txt :I Hello, world! This is a test. ^Z :#W # write buffer to temp file :E # save and end edit (renames original -> .BAK and temp -> original)
Example 2 — Find and replace using S
Given a file with TIME occurrences, replace the first occurrence with PLACE:
:#A # append entire source to buffer
:S TIME^ZPLACE^Z
Example 3 — Use X and R to move blocks
:2X # copy two lines starting at current line into transferred LIB
:R # read transferred lines back at current CP
:0X # clear transferred LIB
Example 4 — Simple macro to change GAMMA -> DELTA
:MFGAMMA^Z-5DIDELTA^Z0TT
Notes
- Commands may be prefixed with absolute line numbers like
123:to move the current line before executing following command. ^Lin search/replace strings represents a CRLF (\r\n).
See docs/COMMANDS.md for a full command reference.