Path: utzoo!mnetor!uunet!mcvax!enea!kuling!irf From: irf@kuling.UUCP (Bo Thide) Newsgroups: comp.editors Subject: 'lvi' -- the learner's 'vi' Message-ID: <608@kuling.UUCP> Date: 18 Jan 88 21:55:38 GMT Reply-To: irf@kuling.UUCP (Bo Thide) Organization: Dept. of Computer Systems, Uppsala University, Sweden Lines: 279 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 ' 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 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 #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&5C("]U(&$* 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/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 TO RETURN FROM INPUT TO COMMAND MODE! Type 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//new/ change FIRST in CURRENT LINE to 'new' :s//new/g change ALL s in CURRENT LINE to 'new' :%s//new/g change ALL s in ALL LINES to 'new' :s/\(\)\(\)/\2new\1/ change FIRST occurrence of in CURRENT LINE to 'new'. :g//s//new$/ ONLY in lines containing change 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//new1&new2/g change ALL s in ALL lines to the combination 'new1''new2' 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 ; 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 key while typing 'X'; 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. / find . E.g. to find "home" type /home (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 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: or If you don't want to quit but INTERRUPT and GO BACK to line 1, type: 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