Xref: utzoo comp.misc:5489 comp.editors:535 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!milano!mister-curious!loo From: loo@mister-curious.sw.mcc.com (Joel Loo) Newsgroups: comp.misc,comp.editors Subject: Re: UNIX needs a real text editor Summary: Some example vi macros Message-ID: <2116@mister-curious.sw.mcc.com> Date: 14 Mar 89 17:17:55 GMT References: <222@imspw6.UUCP> <252@torch.UUCP> <2112@mister-curious.sw.mcc.com> Organization: MCC, Austin, TX Lines: 235 Here are some vi macros. They are very general and are good for beginners. Unpack them as normal archive. Comments and suggestions are welcomed. - Joel Loo #! /bin/sh # 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 mister-curious.sw.mcc.com!loo on Tue Mar 14 11:05:23 CST 1989 # Contents: README jl.ex jl.ex.ref echo x - README sed 's/^@//' > "README" <<'@//E*O*F README//' These are some example vi macros. The simplicity and usefulness of these examples make them good examples for vi beginners. I hope these macros would make life worth living once more for lots of vi beginners. You can either include the "jl.ex" file into your vi init file ".exrc" or use the vi command ":source jl.ex" to load them during your vi session. Comment and suggestions are welcomed. - Joel Loo Peing Ling, Mar 14, 89 @//E*O*F README// chmod u=rw,g=r,o=r README echo x - jl.ex sed 's/^@//' > "jl.ex" <<'@//E*O*F jl.ex//' "Some vi macros "Joel Loo, Feb 15 1989 map V :s$/\* \(.*\) \*/$\1$ map v :s$.*$/* & */$ map W mt`m"dy`t map mt`m"dd`t map Y "dPmm map K :'m,.s/.*/# &/ map :'m,.s/# \(.*\)/\1/ map :e# abbr cmt /* */hhi abbr dcm /* abbr ilv I love vi map ip oprintf(" >\n");4hi @//E*O*F jl.ex// chmod u=rw,g=r,o=r jl.ex echo x - jl.ex.ref sed 's/^@//' > "jl.ex.ref" <<'@//E*O*F jl.ex.ref//' //////////////////////////////////////////////////////////////////////// / EXAMPLES VI MACROS REF. (by loo@mcc.com) / //////////////////////////////////////////////////////////////////////// //////////////////// / cut-paste macros / //////////////////// [The command "mm" marks the starting line of a cut/copy. After proper marking, move the cursor to the ending line of your cut/copy. Use either "^W" or "W" to get the text cut/copied. The command "Y" yanks the cut/ copied text at the cursor position. These commands work across files, unlike the "*y" and "p"/"P" commands.] Command | Meaning ----------------------------------------------------------------------- mm | Mark the beginning of region W | Copy (to scratch) from marked line to current line ^W | Cut (to scratch) from marked line to current line Y | Yank (or paste) from scratch area ////////////// / commenting / ////////////// v | 'C'-comment the current line V | 'C'-uncomment the current line K | Comment with '#' from marked line (good for sh etc.) ^K | Uncomment lines of '#' from mark line (") ///////////////// / Miscellaneous / ///////////////// ^O | Edit the alternate file ///////////////// / abbreviations / ///////////////// [Abbreviation capability is part of vi. The user can define as many as he likes with the ex-command "abbr". Abbreviation works when the exact sequence of chars is typed in the insert mode.] [Important: Need to be in insert mode] Abbreviation | Expansion ------------------------------------------------------------------------------- ilv | "I love vi" cmt | "/* */" and ready for inserting comment text dcm | similar to cmt but for C-function documentation /////////////////// / Escape Commands / /////////////////// [Escape commands capability is not documented but only implied by vi reference. This function might not be in some vi implementations. Using these commands requires fast fingering; you have to press and following by the rest of a command in quick succession.] Command | Meangin ------------------------------------------------------------------------------- ip | Insert 'printf(" >\n");' and ready for inserting print text [Escape commands capability comes in handy when all control and function keys of your keyboard are defined. You can define almost unlimited escape commands.] @//E*O*F jl.ex.ref// chmod u=rw,g=r,o=r jl.ex.ref echo x - jl.ex.shar sed 's/^@//' > "jl.ex.shar" <<'@//E*O*F jl.ex.shar//' # 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 mister-curious.sw.mcc.com!loo on Tue Mar 14 11:05:23 CST 1989 # Contents: README jl.ex jl.ex.ref jl.ex.shar echo x - README sed 's/^@//' > "README" <<'@//E*O*F README//' These are some example vi macros. The simplicity and usefulness of these examples make them good examples for vi beginners. I hope these macros would make life worth living once more for lots of vi beginners. You can either include the "jl.ex" file into your vi init file ".exrc" or use the vi command ":source jl.ex" to load them during your vi session. Comment and suggestions are welcomed. - Joel Loo Peing Ling, Mar 14, 89 @@//E*O*F README// chmod u=rw,g=r,o=r README echo x - jl.ex sed 's/^@//' > "jl.ex" <<'@//E*O*F jl.ex//' "Some vi macros "Joel Loo, Feb 15 1989 map V :s$/\* \(.*\) \*/$\1$ map v :s$.*$/* & */$ map W mt`m"dy`t map mt`m"dd`t map Y "dPmm map K :'m,.s/.*/# &/ map :'m,.s/# \(.*\)/\1/ map :e# abbr cmt /* */hhi abbr dcm /* abbr ilv I love vi map ip oprintf(" >\n");4hi @@//E*O*F jl.ex// chmod u=rw,g=r,o=r jl.ex echo x - jl.ex.ref sed 's/^@//' > "jl.ex.ref" <<'@//E*O*F jl.ex.ref//' //////////////////////////////////////////////////////////////////////// / EXAMPLES VI MACROS REF. (by loo@mcc.com) / //////////////////////////////////////////////////////////////////////// //////////////////// / cut-paste macros / //////////////////// [The command "mm" marks the starting line of a cut/copy. After proper marking, move the cursor to the ending line of your cut/copy. Use either "^W" or "W" to get the text cut/copied. The command "Y" yanks the cut/ copied text at the cursor position. These commands work across files, unlike the "*y" and "p"/"P" commands.] Command | Meaning ----------------------------------------------------------------------- mm | Mark the beginning of region W | Copy (to scratch) from marked line to current line ^W | Cut (to scratch) from marked line to current line Y | Yank (or paste) from scratch area ////////////// / commenting / ////////////// v | 'C'-comment the current line V | 'C'-uncomment the current line K | Comment with '#' from marked line (good for sh etc.) ^K | Uncomment lines of '#' from mark line (") ///////////////// / Miscellaneous / ///////////////// ^O | Edit the alternate file ///////////////// / abbreviations / ///////////////// [Abbreviation capability is part of vi. The user can define as many as he likes with the ex-command "abbr". Abbreviation works when the exact sequence of chars is typed in the insert mode.] [Important: Need to be in insert mode] Abbreviation | Expansion ------------------------------------------------------------------------------- ilv | "I love vi" cmt | "/* */" and ready for inserting comment text dcm | similar to cmt but for C-function documentation /////////////////// / Escape Commands / /////////////////// [Escape commands capability is not documented but only implied by vi reference. This function might not be in some vi implementations. Using these commands requires fast fingering; you have to press and following by the rest of a command in quick succession.] Command | Meangin ------------------------------------------------------------------------------- ip | Insert 'printf(" >\n");' and ready for inserting print text [Escape commands capability comes in handy when all control and function keys of your keyboard are defined. You can define almost unlimited escape commands.] @@//E*O*F jl.ex.ref// chmod u=rw,g=r,o=r jl.ex.ref