Xref: utzoo comp.lang.c:23991 comp.text:5647 comp.editors:1127 Path: utzoo!attcan!uunet!mcsun!cernvax!ethz!ethz-inf!wyle From: wyle@inf.ethz.ch (Mitchell Wyle) Newsgroups: comp.lang.c,comp.text,comp.editors Subject: summary followup: Vi macros for C programming Keywords: vi, C, map Message-ID: <6102@ethz-inf.UUCP> Date: 24 Nov 89 15:51:49 GMT Reply-To: wyle@ethz.uucp Followup-To: comp.lang.c Organization: Departement Informatik, ETH Zuerich Lines: 109 The replies to my original posting were underwhelming :-( No one sent me a single macro :-( 8-(. How do you write a usenet article which gets replies? Undaunted, I started to write my own set of C programming macros. Check these out: map ;cc :r /usr/local/lib/vi/C_template^M1Gdd map ;in i#include ^M^[kwwwcw map ;de i#define const val^M^M^[kkwwcw map ;ty itypedef struct newtype {^M int i;^M} newtype;^M^[kkkwwcw map ;wh iwhile ( cond ) {^M st;^M}^M^[kkkwwcw map ;fo ifor ( i = 0; i < max; i++ ) {^M st;^M}^[kkwwcw map ;if iif ( cond ) {^M st;^M}^[kkwwcw map ;ie iif ( cond ) {^M st;^M} else {^M st;^M}^[kkkkwwcw map! ;QGF f(x,y)^Mnode *x;^Mint y;^M{^M int i;^M} /* end f */^M^[6kwcw map ;fv ivoid ;QGF map ;fi iint ;QGF map ;ff ifloat ;QGF So what do they do? Well, ;cc reads in a template file which, at the moment, looks like this: ------------------------------------------------------------------------- /* %Z%%M% %I% %E% %U% coder date what ----- ------- --------------------------------------------------------- ynh 00jan90 what */ /* includes */ #include #include /* constants */ #define MaxLineLen 127 /* max line length for buffer */ /* macros */ #define err(a) { fputs(a,stderr); fputs(" Punting.\n",stderr); exit(-1); } /* global variables */ FILE *f; /* file pointer */ char line[MaxLineLen]; /* line buffer for reading the file */ short i,j,k; /* loop indices */ main() { } /* end program */ ---------------------------------------------------------------------------- Then ;in creates a cpp include statement, ;de creates a define. ;ty creates a typedef construct. ;wh a while and ;fo a for statement. These macros are very similar to the electric-Modula-2 set. Of course there is ;if for an if statement, ;ie for an if-then-else. The ;QGF is an insert mode helper-macro for declaring functions. ;fv declares a void function, ;fi an integer and ;ff a float. All macros leave you in change-word mode at the first logical place that you should add text. I haven't started using them in "production" yet, but intend to do so next week. I'll let y'all know what changes I decide to make. Here are the macros packaged in compressed, uuencoded form: begin 654 exrc.Z M'YV0(D"4T%*B1),2(!(*3((P88DB"$M4*:% 1$401=B4&4-'3IHQ+88D3.,& MA)TT(-J$@9,RS!@Y;^: $)('1!,7((S@O))'(X@A;^#D\7@T0*(:D !$C M1PX8+)@ZA5'QHIDT;(><'FS9@P;"BG$?/B MY(LA7\B:1=L@QA$R9!05S6Z0..CP88U=X*/N:-Z M)6O;KT?8ONJ&[QLW6DUB;N![#? [PXLCIE,S#7]\![NG MP4@W1]/L:- '?1GU><#/_VU=./'5.]#U&EUI^(0""&,\1P8(2[67D%;S]5%= M?]C]9]P.9N251H:.'8A2#R# L,-K(/#0$AXCIK'""@R"X.!X=$3(GW_:L;;A M:S<>F* ;"S;H'HPR4I@=@&F E4:.""K8XHL0T@="&6S,P=Z/3?;!GY 6PA$" M:U$<801<*.#!0AXI-.#&&\BI@&(#)!V5QWPOMOE:A(^I\"2/<(&@P@N^V0#< CD!>:8<=K=KR1QH([=&E$C1BB="1\7'K)J!EFO&9&95Y%NBB/ end # Could some kind soul please please send me the vi map macros for editing C code and/or the C-template files posted to comp.sources.misc? Also, I am *STILL* interested in vi map macro code which you find useful. Finally, does someone have a compiled set of statistics for which keystrokes in which order C-coders type at vi? I wrote some code a while back which generates macros from keystroke sequences and could probably change the code generator from EDT to vi pretty quickly. Thanks, -Mitchell F. Wyle Institut fuer Informationssysteme wyle@inf.ethz.ch ETH Zentrum / 8092 Zurich, Switzerland +41 1 256 5237