irf@kuling.UUCP (Bo Thide) (01/19/88)
This is 'lvi', a script for 'vi' learners. The file ..../vi.help is identical to the one in 'nvi' which I posted to comp.editors yesterday. 'lvi' is in use on our HP-UX computers. I have not tested 'lvi' on any other system. Comments/corrections welcome. Enjoy! --Bo >>> Bo Thide', Swedish Institute of Space Physics, S-755 90 Uppsala, Sweden <<< Phone (+46) 18-300020. Telex: 76036 (IRFUPP S). UUCP: ..enea!kuling!irfu!bt #---------------------------------- cut here ---------------------------------- # This is a shell archive. Remove anything before this line, # then unpack it by saving it in a file and typing "sh file". # # Wrapped by bt at irfu on Mon Jan 18 00:11:24 1988 # # This archive contains: # lvi.doc /usr/local/bin/lvi # /usr/local/lib/vi/lvi.map /usr/local/lib/vi/lvi.unmap # /usr/local/lib/vi/vi.help /usr/local/lib/vi/tags/lvi # /usr/local/lib/vi/tags/lvi.init # echo x - lvi.doc cat >lvi.doc <<'@EOF' LVI -- The Learner's introduction to VI (Test Version. Release 0.1 Jan 15, 1988) by Bo Thide' Swedish Institute of Space Physics S-755 90 Uppsala, Sweden UUCP: ..enea!kuling!irfu!bt or bt@irfu.UUCP This is a test version of a macro package providing a learner's interface to the vi(1) editor family. You start by typing 'lvi <filename>' and then a tags file containing an introductory text is displayed. After that, just follow the instructions. You can even safely use a vi(1) command that would normally in some way alter the contents of the tags file since all such dangerous commands have been ":map"ped away. Only if you use ":" followed by an ex(1) command is it possible to damage the tags file. It does not seem to be possible to ":map" ex(1) commands. At least on the system (HP-UX) I have tried such a mapping yields the message "Too dangerous to map that". After hitting ^C you enter into the first of the files you want to edit. At the same time a help line is displayed at the bottom of the screen. This line also appears when you hit <CR> in command mode, something that unexperienced users tend to do now and then. In all other respects, vi(1) now behaves in a normal way. @EOF chmod 644 lvi.doc echo Compiling unpacker for non-ascii files pwd=`pwd`; cd /tmp cat >unpack$$.c <<'EOF' #include <stdio.h> #define DEC(c) (((c) - ' ') & 077) main() { int n; char dest[128], a,b,c,d; scanf("begin %o ", &n); gets(dest); if (freopen(dest, "w", stdout) == NULL) { perror(dest); exit(1); } while ((n=getchar()) != EOF && (n=DEC(n))!=0) { while (n>0) { a = DEC(getchar()); b = DEC(getchar()); c = DEC(getchar()); d = DEC(getchar()); if (n-- > 0) putchar(a << 2 | b >> 4); if (n-- > 0) putchar(b << 4 | c >> 2); if (n-- > 0) putchar(c << 6 | d); } n=getchar(); } exit(0); } EOF cc -o unpack$$ unpack$$.c rm unpack$$.c cd $pwd echo x - /usr/local/bin/lvi '[non-ascii]' /tmp/unpack$$ <<'@eof' begin 755 /usr/local/bin/lvi M:68@6R D(R ](# @70H@('1H96X@96-H;R B57-A9V4Z("0P(#QF:6QE;F%M M93XB"B @97AI=" Q"F9I( II9B!;("$@+7,@)#$@70H@('1H96X@96-H;R G M)R ^("0Q"F9I"DU/4D4])RUC9#(R)PIE>'!O<G0@34]210I%6$E.250](B1% M6$E.251<"GQS970@;F]A=71O=W)I=&5<"GQS970@=&%G<STO=7-R+VQO8V%L M+VQI8B]V:2]T86=S+VQV:5P*?&UA<" !(#HA8VQE87([;6]R92 O=7-R+VQO M8V%L+VQI8B]V:2]V:2YH96QP#5P*?&!C870@+W5S<B]L;V-A;"]L:6(O=FDO M;'9I+FUA<&!<"B(*97AP;W)T($5824Y)5 IE>&5C("]U<W(O8FEN+W9E9&ET ,("UT(&EN:70@)"H* end @eof chmod 755 /usr/local/bin/lvi echo x - /usr/local/lib/vi/lvi.map '[non-ascii]' /tmp/unpack$$ <<'@eof' begin 644 /usr/local/lib/vi/lvi.map M.FUA<" #(#IR97<-.G-O("]U<W(O;&]C86PO;&EB+W9I+VQV:2YU;FUA< TZ M(D5N=&5R(#Q#5%),/BU!(&9O<B!!<W-I<W1A;F-E+@T*.FUA<"!A(#HB3F]T M('EE="$@2&ET('$@=&\@8F%I;"!O=70L(%Y#('1O(&-O;G1I;G5E+"!O<B Z M(6UA;B!V:3Q#4CX@9F]R(&UO<F4@:6YF;RX-"CIM87 @02!A"CIM87 @8R!A M"CIM87 @0R!A"CIM87 @9"!A"CIM87 @1"!A"CIM87 @:2!A"CIM87 @22!A M"CIM87 @2B!A"CIM87 @;R!A"CIM87 @3R!A"CIM87 @<"!A"CIM87 @4"!A M"CIM87 @<2 S-$<Z<2$*.FUA<"!1(&$*.FUA<"!R(&$*.FUA<"!2(&$*.FUA M<"!S(&$*.FUA<"!3(&$*.FUA<"!U(&$*.FUA<"!5(&$*.FUA<"!X(&$*.FUA M<"!8(&$*.FUA<" A(&$*.FUA<" F(&$*.FUA<" N(&$*.FUA<" \(&$*.FUA A<" ^(&$*.FUA<"!^(&$*.FUA<" =(&$*.FUA<" >(&$* end @eof chmod 644 /usr/local/lib/vi/lvi.map echo x - /usr/local/lib/vi/lvi.unmap '[non-ascii]' /tmp/unpack$$ <<'@eof' begin 644 /usr/local/lib/vi/lvi.unmap M.G5N;6%P( ,*.G5N;6%P($$*.G5N;6%P(&,*.G5N;6%P($,*.G5N;6%P(&0* M.G5N;6%P($0*.G5N;6%P(&D*.G5N;6%P($D*.G5N;6%P($H*.G5N;6%P(&\* M.G5N;6%P($\*.G5N;6%P(' *.G5N;6%P(% *.G5N;6%P('$*.G5N;6%P(%$* M.G5N;6%P('(*.G5N;6%P(%(*.G5N;6%P(',*.G5N;6%P(%,*.G5N;6%P('4* M.G5N;6%P(%4*.G5N;6%P('@*.G5N;6%P(%@*.G5N;6%P("$*.G5N;6%P("8* M.G5N;6%P("X*.G5N;6%P(#P*.G5N;6%P(#X*.G5N;6%P('X*.G5N;6%P(!T* M.G5N;6%P(!X*.G5N;6%P(&$*.G5N;6%P( $*.FUA<" -(#HB16YT97(@/$-4 M4DP^+4$@9F]R($%S<VES=&%N8V4-*PHZ;6%P( $@.B%C;&5A<CMM;W)E("]U M<W(O;&]C86PO;&EB+W9I+W9I+FAE;' ;#0HZ;6%P(2 !(!LZ(6-L96%R.VUO @<F4@+W5S<B]L;V-A;"]L:6(O=FDO=FDN:&5L<!L-80H! end @eof chmod 644 /usr/local/lib/vi/lvi.unmap echo x - /usr/local/lib/vi/vi.help cat >/usr/local/lib/vi/vi.help <<'@EOF' a [A] append after cursor [line] w [W] word ["word"] b [B] back one word ["word"] x [X] cross out char at [before] cursor c [C] change next [to end of line] y [Y] yank next [whole line] d [D] delete next [to end of line] zpos redraw zone at pos (.,-, or CR) e [E] end of word ["word"] ZZ write changes to file, exit editor f [F] find next [previous] in line ^B[^F] backward [forward] paging G [nG] go to last [nth] line in file ^D[^U] downward [upward] scrolling h [l] cursor left [right] ^D[^T] delete [tab] one sw during insert H [L] to home [last] line on screen ^E[^Y] expose 1 more line at bottom [top] i [I] insert before cursor [line] ^G get file name and statistics j [k] cursor down [up] ~ change case (upper/lower) of char J join line with next + [-] to first char in next [prev] line mx[`x] mark [return to] position 'x' 0 [$] to first [last] character in line M to midpoint on screen ; [,] repeat [reverse] last f,F,t, or T n [N] to next [previous] occurrence . repeat last change of the text o [O] open a line below [above] <<[>>] shift line one sw left [right] p [P] put in after [before] ( [)] to beginning of [next] sentence Q quit 'vi', go to 'ex' { [}] to beginning of [next] paragraph r [R] replace 1 [all] character[s] / [?] search forward [backward] s [S] substitute next [to end of line]``[''] return to previous position [line] t [T] to next [previous] in line : [:!] execute 'ex' [shell] command u [U] undo last change in file [line] ! [!!] shell command on next [this line] PREPEND BY n TO REPEAT n TIMES. TYPE <ESC> TO RETURN FROM INPUT TO COMMAND MODE! Type <ESC><ESC> and wait for 'vi' to confirm with a beep that it is in command mode. Then a large variety of ':' ("last line commands") are avilable: SUBSTITUTIONS: :s/<pattern>/new/<CR> change FIRST <pattern> in CURRENT LINE to 'new' :s/<pattern>/new/g<CR> change ALL <pattern>s in CURRENT LINE to 'new' :%s/<pattern>/new/g<CR> change ALL <pattern>s in ALL LINES to 'new' :s/\(<pat1>\)\(<pat2>\)/\2new\1/ change FIRST occurrence of <pat1><pat2> in CURRENT LINE to <pat2>'new'<pat1>. :g/<pat1>/s/<pat2>/new$/ ONLY in lines containing <pat1> change <pat2> to 'new' ONLY AT THE END OF THE LINE. :.,+ns/^./new/ change in CURRENT and FOLLOWING n lines ANY character at the BEGINNING of the line to 'new' :%s/<pattern>/new1&new2/g change ALL <pattern>s in ALL lines to the combination 'new1'<pattern>'new2' <pattern> means aaa the string 'aaa' [aA]aa the string 'aaa' OR the string 'Aaa' [^A]aa the string 'xaa' where 'x' is any character EXCEPT 'A' a* the strings '', 'a', 'aa', 'aaa', ... plus more advanced types of <patterns>; see tutorials on 'ed', 'ex' and 'vi'. Such patterns can also be used in searches ('/' and '?' on the previous page). Type 'u' to undo a substitution! @EOF chmod 644 /usr/local/lib/vi/vi.help echo x - /usr/local/lib/vi/tags/lvi cat >/usr/local/lib/vi/tags/lvi <<'@EOF' delete /usr/local/lib/vi/tags/lvi.delete 1 help /usr/local/lib/vi/tags/lvi.help 1 init /usr/local/lib/vi/tags/lvi.init 1 insert /usr/local/lib/vi/tags/lvi.insert 1 move /usr/local/lib/vi/tags/lvi.move 1 quit /usr/local/lib/vi/tags/lvi.quit 1 @EOF chmod 644 /usr/local/lib/vi/tags/lvi echo x - /usr/local/lib/vi/tags/lvi.init cat >/usr/local/lib/vi/tags/lvi.init <<'@EOF' This is 'lvi' - the learner's introduction to the visual editor 'vi'. -----------------------------------------------------------------------bt 870830 Only an emergency exit command 'q' and some safe 'vi' "move-around" commands can be used at this point. (Try them out! Always type '1G' to return to this page): (^X means holding down <CTRL> key while typing 'X'; <CR> means carriage return) q quit 'lvi' here and now. WARNING: NO CHANGES RECORDED! ZZ quit 'lvi' after recording changes in your file(s). ^F (^B) Forward (Backward) page by page. ^D (^U) Downward (Upward) scrolling. h j k l move cursor left, down, up, and right, respectively. 1G go to line 1 in the file. nG for line n, G for last line. /<pattern><CR> find <pattern>. E.g. to find "home" type /home<CR> (Try it!) ^L redraw screen ("Form Feed"). ^C Continue your editing session. Valid only here in help mode! Typing ^C will take you into command mode in the first file. There you may use ALL 'vi' commands, e.g. 'a' for Appending text and <ESC> to end the text insert/ append mode. At any time during your editing session you may get help by typing: ^A get Assistance. Valid both here and in normal 'lvi' modes! -------------------------------------------------------------------------------- If you really want to QUIT WITHOUT RECORDING ANY CHANGES, type: <CR> or <ESC> If you don't want to quit but INTERRUPT and GO BACK to line 1, type: <DEL>1G @EOF chmod 644 /usr/local/lib/vi/tags/lvi.init rm /tmp/unpack$$ exit 0 -- >>> Bo Thide', Swedish Institute of Space Physics, S-755 90 Uppsala, Sweden <<< Phone (+46) 18-300020. Telex: 76036 (IRFUPP S). UUCP: ..enea!kuling!irfu!bt