186d7f5d3SJohn Marinoprepare to add text at beginning of file:0a|1i 286d7f5d3SJohn Marinofind name of file being edited:f 386d7f5d3SJohn Marinoprint last 3 lines of file:$-[2|-],$p 486d7f5d3SJohn Marinoprint previous line:[-|^]{p}|{.}-{1}{p} 586d7f5d3SJohn Marinoprint whole file:1,$p|g/[^|$]/p 686d7f5d3SJohn Marinodelete this line and next:.{,|;}[{.}+{1}|.1]d 786d7f5d3SJohn Marinoprepare to replace text from here to just before next "PP":\ 886d7f5d3SJohn Marino.{,|;}/[PP|{^}\\.PP]/-{1}c 986d7f5d3SJohn Marinofind next "1.2":/1\\.2/{p} 1086d7f5d3SJohn Marinofind next 2-or-more digit number:\ 1186d7f5d3SJohn Marino/\[[0|1]-9\]\[0-9\]/{p} 1286d7f5d3SJohn Marinomove rest of this paragraph (separated by "PP") to end of previous one:\ 1386d7f5d3SJohn Marino[.,|{.}+{1},|.1,]/[PP|{^}\\.PP]/-{1}m[??|?{^}{\\.}PP?]-{1} 1486d7f5d3SJohn Marinoprint every "Oxygen" or "oxygen":[g|1,$g]/\[[Oo|oO]\]xygen/[p|.p] 1586d7f5d3SJohn Marinochange each "BTL" in file to "Bell Laboratories" and check:\ 1686d7f5d3SJohn Marino[g|1,$g]/BTL/[s|.s]/[/|BTL/]Bell Laboratories/gp 1786d7f5d3SJohn Marinocombine every even-numbered line with the next odd-numbered line:\ 1886d7f5d3SJohn Marino2,${-{1}}g/[^|$]/[j|.,{.}+{1}j|.,.1j] 1986d7f5d3SJohn Marinoprint next "SH" and following line:\ 2086d7f5d3SJohn Marino/SH/;[{.}+{1}|.1]p|/SH/,[//|/SH/][{.}+{1}|.1]p 2186d7f5d3SJohn Marinoprint from next "TS" to following "TE":/TS/;/TE/p 2286d7f5d3SJohn Marinoreverse order of lines in whole file:[g|1,$g]/^/[m|.m]0 2386d7f5d3SJohn Marinoreplace each string of x's in current line by one x:\ 2486d7f5d3SJohn Marino[s|.s]/[x|\[x\]][x|\[x\]]*/x/g{p}{ (not s/x*/x/g)} 2586d7f5d3SJohn Marinochange first "hte" in current line to "the" and check:[s|.s]/hte/the/p 2686d7f5d3SJohn Marinocombine previous line and this one:\ 2786d7f5d3SJohn Marino[-,|^,|{.}-{1},].j 2886d7f5d3SJohn Marinogo to line after third "PP" ahead:\ 2986d7f5d3SJohn Marino/[PP|{^}\\.PP]/;[//|/[PP|{^}\\.PP]/];[//|/[PP|{^}\\.PP]/]\ 3086d7f5d3SJohn Marino[{+}1|+]|;[{.}+{1}|.1]{ (not ...p)} 3186d7f5d3SJohn Marinoexchange current line with previous line:\ 3286d7f5d3SJohn Marino[[-|^]m|{.}-{1}m].|{.}m[[--|^^]|{.}-2] 3386d7f5d3SJohn Marinomove everything from here through "stop." to end of file:\ 3486d7f5d3SJohn Marino.,/stop\\./m$ 3586d7f5d3SJohn Marinocurrent line has 2 fields separated by 1 blank; exchange them:\ 3686d7f5d3SJohn Marino[s|.s]/[\\|^\\]([.|\[^ \]]*\\) \\([.|\[^ \]]*\\)[/|$/]\\2 \\1/{p} 3786d7f5d3SJohn Marinoinsert a "0" after last "0" on current line:\ 3886d7f5d3SJohn Marino[s|.s]/[.*0/&0|^.*0/&0|0\\(\[^0\]*\\)$/[0&|00\1]|0\[^0\]*$/0&\ 3986d7f5d3SJohn Marino|\[^0\]*$/0&]/{p} 4086d7f5d3SJohn Marinoreplace "a*b" by "a**b":s/[a\\*b|a[*]b]/a**b/{p}|\ 4186d7f5d3SJohn Marinos/\\*/**/p 4286d7f5d3SJohn Marinoattach the word "extra" to the end of the current line:\ 4386d7f5d3SJohn Marino[s|.s]/$/{ }extra/{p} 4486d7f5d3SJohn Marinoreplace "ATT" in current line by "AT&T":\ 4586d7f5d3SJohn Marino[s|.s]/ATT/AT\\&T/{g}{p} 4686d7f5d3SJohn Marinodouble the length of the current line by repetition:\ 4786d7f5d3SJohn Marino[s|.s]/[.*|.|^.*$]/&&/{p} 4886d7f5d3SJohn Marinolook for another line containing what you just looked for:// 4986d7f5d3SJohn Marinofind the previous line that contains a capital letter:?\[A-Z\]?{p} 5086d7f5d3SJohn Marinodelete the next line that contains only capital letters:\ 5186d7f5d3SJohn Marino/^\[A-Z\]*$/d|/^\[A-Z\]\[A-Z\]*$/d 5286d7f5d3SJohn Marinoplace a copy of current line at the end of the file:\ 5386d7f5d3SJohn Marinot$|.{,.}t$ 5486d7f5d3SJohn Marinofind how many lines there are:=|$= 5586d7f5d3SJohn Marinofind the number of the current line:.= 5686d7f5d3SJohn Marinodelete the first 3 lines of the file:1,3d 5786d7f5d3SJohn Marinodelete every line that doesn't begin with "A":\ 5886d7f5d3SJohn Marino[v|1,$v]/^A/d{ (not g/^\[^A\]/d)} 5986d7f5d3SJohn Marinodelete every empty line from here through next "LP":\ 6086d7f5d3SJohn Marino.,/[LP|{{^}\\.}LP]/g/^$/d 6186d7f5d3SJohn Marinoprint the line after each "AU":\ 6286d7f5d3SJohn Marino[g|1,$g]/[AU|{^}\\.AU]/[{.}+{1}|.1]{p} 6386d7f5d3SJohn Marinodelete everything after "proud" from current line:\ 6486d7f5d3SJohn Marino[s|.s]/proud.*/proud/{p} 6586d7f5d3SJohn Marinodelete part of current line from "alpha" through "omega":\ 6686d7f5d3SJohn Marino[s|.s]/alpha.*omega//{p} 6786d7f5d3SJohn Marinosave everything up through current line in file "prefix":1,.w prefix 6886d7f5d3SJohn Marinoprepare to add text at end of file:$a 6986d7f5d3SJohn Marinoappend the contents of file "suffix" to this file:$r suffix 7086d7f5d3SJohn Marinogo back 10 lines:{.}-10{p}|---------- 7186d7f5d3SJohn Marinochange every "01" in current line to "1":[s|.s]/01/1/g{p} 7286d7f5d3SJohn Marinogo to next line that contains a double capital letter:\ 7386d7f5d3SJohn Marino/\\(\[A-Z\]\\)\\1/{p} 7486d7f5d3SJohn Marinoplace parens () around current line:\ 7586d7f5d3SJohn Marino[s|.s]/[.*|^.*$]/(&)/{p} 7686d7f5d3SJohn Marinothe current line is too long for your terminal; print it to fit:\ 7786d7f5d3SJohn Marinol|.l 7886d7f5d3SJohn Marinoput the work you've done back in the original file:w 7986d7f5d3SJohn Marinoappend the whole file to the file "unfinished":\ 8086d7f5d3SJohn Marino[W|1,$W] unfinished 8186d7f5d3SJohn Marinoinsert "\\&" at beginning of current line:\ 8286d7f5d3SJohn Marino[s|.s]/^/\\\\\\&/{p} 8386d7f5d3SJohn Marinolist your current directory:!ls 8486d7f5d3SJohn Marinostop work on current file and shift to file "other":e other 85