1 1.1 cgd prepare to add text at beginning of file:0a|1i 2 1.1 cgd find name of file being edited:f 3 1.1 cgd print last 3 lines of file:$-[2|-],$p 4 1.1 cgd print previous line:[-|^]{p}|{.}-{1}{p} 5 1.1 cgd print whole file:1,$p|g/[^|$]/p 6 1.1 cgd delete this line and next:.{,|;}[{.}+{1}|.1]d 7 1.1 cgd prepare to replace text from here to just before next "PP":\ 8 1.1 cgd .{,|;}/[PP|{^}\\.PP]/-{1}c 9 1.1 cgd find next "1.2":/1\\.2/{p} 10 1.1 cgd find next 2-or-more digit number:\ 11 1.1 cgd /\[[0|1]-9\]\[0-9\]/{p} 12 1.1 cgd move rest of this paragraph (separated by "PP") to end of previous one:\ 13 1.1 cgd [.,|{.}+{1},|.1,]/[PP|{^}\\.PP]/-{1}m[??|?{^}{\\.}PP?]-{1} 14 1.1 cgd print every "Oxygen" or "oxygen":[g|1,$g]/\[[Oo|oO]\]xygen/[p|.p] 15 1.1 cgd change each "BTL" in file to "Bell Laboratories" and check:\ 16 1.1 cgd [g|1,$g]/BTL/[s|.s]/[/|BTL/]Bell Laboratories/gp 17 1.1 cgd combine every even-numbered line with the next odd-numbered line:\ 18 1.1 cgd 2,${-{1}}g/[^|$]/[j|.,{.}+{1}j|.,.1j] 19 1.1 cgd print next "SH" and following line:\ 20 1.1 cgd /SH/;[{.}+{1}|.1]p|/SH/,[//|/SH/][{.}+{1}|.1]p 21 1.1 cgd print from next "TS" to following "TE":/TS/;/TE/p 22 1.1 cgd reverse order of lines in whole file:[g|1,$g]/^/[m|.m]0 23 1.1 cgd replace each string of x's in current line by one x:\ 24 1.1 cgd [s|.s]/[x|\[x\]][x|\[x\]]*/x/g{p}{ (not s/x*/x/g)} 25 1.1 cgd change first "hte" in current line to "the" and check:[s|.s]/hte/the/p 26 1.1 cgd combine previous line and this one:\ 27 1.1 cgd [-,|^,|{.}-{1},].j 28 1.1 cgd go to line after third "PP" ahead:\ 29 1.1 cgd /[PP|{^}\\.PP]/;[//|/[PP|{^}\\.PP]/];[//|/[PP|{^}\\.PP]/]\ 30 1.1 cgd [{+}1|+]|;[{.}+{1}|.1]{ (not ...p)} 31 1.1 cgd exchange current line with previous line:\ 32 1.1 cgd [[-|^]m|{.}-{1}m].|{.}m[[--|^^]|{.}-2] 33 1.1 cgd move everything from here through "stop." to end of file:\ 34 1.1 cgd .,/stop\\./m$ 35 1.1 cgd current line has 2 fields separated by 1 blank; exchange them:\ 36 1.1 cgd [s|.s]/[\\|^\\]([.|\[^ \]]*\\) \\([.|\[^ \]]*\\)[/|$/]\\2 \\1/{p} 37 1.1 cgd insert a "0" after last "0" on current line:\ 38 1.1 cgd [s|.s]/[.*0/&0|^.*0/&0|0\\(\[^0\]*\\)$/[0&|00\1]|0\[^0\]*$/0&\ 39 1.1 cgd |\[^0\]*$/0&]/{p} 40 1.1 cgd replace "a*b" by "a**b":s/[a\\*b|a[*]b]/a**b/{p}|\ 41 1.1 cgd s/\\*/**/p 42 1.1 cgd attach the word "extra" to the end of the current line:\ 43 1.1 cgd [s|.s]/$/{ }extra/{p} 44 1.1 cgd replace "ATT" in current line by "AT&T":\ 45 1.1 cgd [s|.s]/ATT/AT\\&T/{g}{p} 46 1.1 cgd double the length of the current line by repetition:\ 47 1.1 cgd [s|.s]/[.*|.|^.*$]/&&/{p} 48 1.1 cgd look for another line containing what you just looked for:// 49 1.1 cgd find the previous line that contains a capital letter:?\[A-Z\]?{p} 50 1.1 cgd delete the next line that contains only capital letters:\ 51 1.1 cgd /^\[A-Z\]*$/d|/^\[A-Z\]\[A-Z\]*$/d 52 1.1 cgd place a copy of current line at the end of the file:\ 53 1.1 cgd t$|.{,.}t$ 54 1.1 cgd find how many lines there are:=|$= 55 1.1 cgd find the number of the current line:.= 56 1.1 cgd delete the first 3 lines of the file:1,3d 57 1.1 cgd delete every line that doesn't begin with "A":\ 58 1.1 cgd [v|1,$v]/^A/d{ (not g/^\[^A\]/d)} 59 1.1 cgd delete every empty line from here through next "LP":\ 60 1.1 cgd .,/[LP|{{^}\\.}LP]/g/^$/d 61 1.1 cgd print the line after each "AU":\ 62 1.1 cgd [g|1,$g]/[AU|{^}\\.AU]/[{.}+{1}|.1]{p} 63 1.1 cgd delete everything after "proud" from current line:\ 64 1.1 cgd [s|.s]/proud.*/proud/{p} 65 1.1 cgd delete part of current line from "alpha" through "omega":\ 66 1.1 cgd [s|.s]/alpha.*omega//{p} 67 1.1 cgd save everything up through current line in file "prefix":1,.w prefix 68 1.1 cgd prepare to add text at end of file:$a 69 1.1 cgd append the contents of file "suffix" to this file:$r suffix 70 1.1 cgd go back 10 lines:{.}-10{p}|---------- 71 1.1 cgd change every "01" in current line to "1":[s|.s]/01/1/g{p} 72 1.1 cgd go to next line that contains a double capital letter:\ 73 1.1 cgd /\\(\[A-Z\]\\)\\1/{p} 74 1.1 cgd place parens () around current line:\ 75 1.1 cgd [s|.s]/[.*|^.*$]/(&)/{p} 76 1.1 cgd the current line is too long for your terminal; print it to fit:\ 77 1.1 cgd l|.l 78 1.1 cgd put the work you've done back in the original file:w 79 1.1 cgd append the whole file to the file "unfinished":\ 80 1.1 cgd [W|1,$W] unfinished 81 1.1 cgd insert "\\&" at beginning of current line:\ 82 1.1 cgd [s|.s]/^/\\\\\\&/{p} 83 1.1 cgd list your current directory:!ls 84 1.1 cgd stop work on current file and shift to file "other":e other 85