EDAM(1)
EDAM(1) πΈ
okay so bestie, this is the manual page for edam β a multi-file line editor with structural regular expressions β and it is lowkey iconic. buckle up, weβre going in π
π NAME π
edam β multi-file line editor with structural regular expressions
β¨ SYNOPSIS β¨
edam [ -d ] [ files ]
edam.save
π¦ DESCRIPTION π¦
okay so edam is a multi-file editor. it modifies a local copy of a Unix file. the copy is here called a file; a Unix file is distinguished by the trademarked adjective. the files are listed in a menu available through the n command.
each file has an associated name β usually the name of the Unix file from which it was read β and a modified bit that indicates whether the editorβs file agrees with the Unix file. the Unix file is not read into the editorβs file until it first becomes the current file β that is, the file to which editing commands apply β whereupon its menu entry is printed. periodt.
the options are:
-dβ ignored. here for compatibility with originalsam(1).
π Regular expressions π
regular expressions are as in egrep (see gre(1)), with the addition of @ and \n.
π¨ bestie, a regular expression may never contain a literal newline character. no cap.
the elements of regular expressions are:
.β match any character except newline.\nβ match newline.\xβ for any character exceptn, match the character (herex).@β match any character.[abc]β match any character in the square brackets.\nmay be mentioned.[^abc]β match any character not in the square brackets, but never a newline. both these forms accept a range of characters indicated by a dash, as ina-z.^β match the null string immediately after a newline.$β match the null string immediately before a newline.
any other character except newline matches itself.
in the following, r1 and r2 are regular expressions.
(r1)β match whatr1matches.r1|r2β match whatr1or whatr2matches.r1*β match zero or more adjacent matches ofr1.r1+β match one or more adjacent matches ofr1.r1?β match zero or one matches ofr1.
the operators *, + and ? are highest precedence, then catenation, then | is lowest. the empty regular expression stands for the last complete expression encountered. a regular expression in edam matches the longest leftmost substring formally matched by the expression. searching in the reverse direction is equivalent to searching backwards with the catenation operations reversed in the expression.
π§ Addresses π§
an address identifies a substring in a file. in the following, character n means the null string after the n-th character in the file, with 1 the first character in the file. Line n means the n-th match, starting at the beginning of the file, of the regular expression .*\n?. (the peculiar properties of a last line without a newline are temporarily undefined.) all files always have a current substring, called dot, that is the default address.
πΈ Simple Addresses πΈ
#nβ the empty string after charactern;#0is the beginning of the file.nβ linen./regexp/and?regexp?β the substring that matches the regular expression, found by looking toward the end (/) or beginning (?) of the file, and if necessary continuing the search from the other end to the starting point of the search. the matched substring may straddle the starting point.0β the string before the first full line. this is not necessarily the null string; see+and-below.$β the null string at the end of the file..β dot.'β the mark in the file (see thekcommand below)."regexp"β preceding a simple address (default.), refers to the address evaluated in the unique file whose menu line matches the regular expression.
π Compound Addresses π
in the following, a1 and a2 are addresses.
a1+a2β the addressa2evaluated starting at the end ofa1.a1-a2β the addressa2evaluated looking in the reverse direction starting at the beginning ofa1.a1,a2β the substring from the beginning ofa1to the end ofa2. ifa1is missing,0is substituted. ifa2is missing,$is substituted.a1;a2β likea1,a2, but witha2evaluated at the end of, and dot set to,a1.
the operators + and - are high precedence, while , and ; are low precedence.
in both + and - forms, if a2 is a line or character address with a missing number, the number defaults to 1. if a1 is missing, . is substituted. if both a1 and a2 are present and distinguishable, + may be elided. a2 may be a regular expression; if it is delimited by ?βs, the effect of the + or - is reversed.
it is an error for a compound address to represent a malformed substring. some useful idioms: a1+- (a1-+) selects the line containing the end (beginning) of a1. 0/regexp/ locates the first match of the expression in the file. (the form 0;// sets dot unnecessarily.) ./regexp/// finds the second following occurrence of the expression, and .,/regexp/ extends dot.
π Commands π
in the following, text demarcated by slashes represents text delimited by any printable ASCII character except alphanumerics. any number of trailing delimiters may be elided, with multiple elisions then representing null strings, but the first delimiter must always be present. in any delimited text, newline may not appear literally; \n may be typed for newline; and \/ quotes the delimiter, here /. backslash is otherwise interpreted literally, except in s commands.
most commands may be prefixed by an address to indicate their range of operation. those that may not are marked with a * below. if a command takes an address and none is supplied, dot is used. the sole exception is the w command, which defaults to 0,$. in the description, range is used to represent whatever address is supplied. many commands set the value of dot as a side effect. if so, it is always set to the result of the change: the empty string for a deletion, the new text for an insertion, etc. (but see the s and e commands).
π«Ά Text commands π«Ά
a/text/orafollowed by lines of text, ending with.β insert the text into the file after the range. set dot.c,iβ same asa, butcreplaces the text, whileiinserts before the range.dβ delete the text in the range. set dot.s/regexp/text/β substitutetextfor the first match to the regular expression in the range. set dot to the modified range. intext, the character&stands for the string that matched the expression. backslash behaves as usual unless followed by a digit:\dstands for the string that matched the subexpression begun by thed-th left parenthesis. ifsis followed immediately by a numbern, as ins2/x/y/, then-th match in the range is substituted. if the command is followed by ag, as ins/x/y/g, all matches in the range are substituted.m a1,t a1β move the range to aftera1(m), or copy it (t). set dot.
β Display commands β
pβ print the text in the range. set dot.=β print the line address and character address of the range.=#β print just the character address of the range.
π File commands π
in these commands a file-list may be expressed <Unix-command, in which case the file names are taken as words (in the shell sense) generated by the Unix command.
- *
b file-listβ set the current file to the first file named in the list thatedamalso has in its menu. - *
B file-listβ same asb, except that file names not in the menu are entered there, and all file names in the list are examined. - *
nβ print a menu of files. the format is:'or blank β indicating the file is modified or clean,-or+β indicating the file is unread or has been read,.or blank β indicating the current file,- a blank,
- and the file name.
- *
D file-listβ delete the named files from the menu. if no files are named, the current file is deleted. it is an error toDa modified file, but a subsequentDwill delete such a file.
π I/O Commands π
- *
e filenameβ replace the file by the contents of the named Unix file. set dot to the beginning of the file. r filenameβ replace the text in the range by the contents of the named Unix file. set dot.w filenameβ write the range (default0,$) to the named Unix file.- *
f filenameβ set the file name and print the resulting menu entry.
if the file name is absent from any of these, the current file name is used. e always sets the file name, r and w do so if the file has no name.
< Unix-commandβ replace the range by the standard output of the Unix command.> Unix-commandβ sends the range to the standard input of the Unix command.| Unix-commandβ send the range to the standard input, and replace it by the standard output, of the Unix command.- *
! Unix-commandβ run the Unix command. - *
cd directoryβ change working directory. if no directory is specified,$HOMEis used.
in any of <, >, | or !, if the Unix command is omitted the last Unix command (of any type) is substituted.
π₯ Loops and Conditionals π₯
x/regexp/ commandβ for each match of the regular expression in the range, run the command with dot set to the match. set dot to the last match. if the regular expression and its slashes are omitted,/.*\n/is assumed. null string matches potentially occur before every character of the range and at the end of the range.y/regexp/ commandβ likex, but run the command for each substring that lies before, between, or after the matches that would be generated byx. there is no default behavior. null substrings potentially occur before every character in the range.- *
X/regexp/ commandβ for each file whose menu entry matches the regular expression, run the command. if the expression is omitted, the command is run in every file. - *
Y/regexp/ commandβ same asX, but for files that do not match the regular expression, and the expression is required. g/regexp/ command,v/regexp/ commandβ if the range contains (g) or does not contain (v) a match for the expression, set dot to the range and run the command.
these may be nested arbitrarily deeply, but only one instance of either X or Y may appear in a single command. an empty command in an x or y defaults to p; an empty command in X or Y defaults to f. g and v do not have defaults.
π Miscellany π
kβ set the current fileβs mark to the range. does not set dot.qβ Quit πͺ. It is an error to quit with modified files, but a secondqwill succeed. (Yes bestie, it's a "are you sure" that you answer by just doing it again π)u nβ Undo the last n (default 1) top-level commands that changed the contents or name of the current file, and any other file whose most recent change was simultaneous with the current file's change. Successiveu's move further back in time βͺ. The only commands for whichuis ineffective arecd,u,q,wandD. Not me trying to undo my undo π- (empty) β If the range is explicit, set dot to the range, and print it. If no address is specified (the command is a newline) dot is extended in either direction to line boundaries and printed. If dot is thereby unchanged, it is set to
.+1and printed.
π Grouping and multiple changes π
Okay so this is the part where it gets chef's kiss β¨ β commands may be grouped by enclosing them in braces {}. Commands within the braces must appear on separate lines (no backslashes are required between commands β we love low-effort syntax π
). Semantically, an opening brace is like a command: it takes an (optional) address and sets dot for each sub-command. Commands within the braces are executed sequentially, but changes made by one command are not visible to other commands (see the next section of this manual π). Braces may be nested arbitrarily β go as deep as your heart desires, bestie π.
When a command makes a number of changes to a file, as in x/re/c/text/, the addresses of all changes to the file are computed in the original file. If the changes are in sequence, they are applied to the file. Successive insertions at the same address are catenated into a single insertion composed of the several insertions in the order applied. π§΅
π Abnormal termination π
If edam terminates other than by a q command (by hangup, deleting its layer, etc.), modified files are saved in an executable file, $HOME/edam.save. This program, when executed, asks whether to write each file back to a Unix file. The answer y causes writing; anything else skips the file.
π¨ Real talk: if your session goes down without a q, you didn't lose everything β but you did get a whole little rescue program, so go run it π«Ά.
π FILES π
$HOME/edam.save
π SEE ALSO π
That's the whole ride, bestie β EDAM(1), page done, no cap πππ¦ Go forth and <kbd>Ctrl</kbd>-less, group your commands, and remember to q twice if you have to πβ¨
π¦ where this page comes from
- alpine 3.24: edam-doc 1.0.2-r1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms