" common exrc source " " set terse " because we prefer terse error messages, set writeany autowrite " because we want to write out our file whenever we can, " like on a :tag, :stop, or :next set tabstop=8 " so tabs look right for us set shiftwidth=4 " so ^T and << are smaller set report=1 " so we our told whenever we affect more than 1 line "set nomesg " because being talked to during an edit is aggravating set autoindent " so i don't have to tab in set redraw optimize " keep the screen tidy " " " INPUT MACROS that i always want active " map!  :stop " so i can stop in input mode. note that autowrite is set, so "map!  :stop! " will stop me without writing. " commented out cause causes bug " map! O " lets me do kindof a negative carriage return in input mode. map!  bi " non-destructive ^W map!  Ea " and its inverse " " ARROW MACROS next four let arrows keys work in insert mode; map! OA ka map! OB ja map! OC lli map! OD i " " Who says you can't emulate emacs in vi? :-) " map!  i map!  lli map!  I map!  A " " " EXCHANGE MACROS -- for exchanging things " map v xp " exchange current char with next one in edit mode map V :m+1 " exchange current line with next one in edit mode map!  hxpa " exchange last typed char with penultimate one in insert mode map =  " edit previously editted file " " " " other macros " map  :w " write out the file " map * i  " split line " map g G " because it's easier to type " map  :stop! " unconditional stop map ' ` " so we return to exact position, not just ^ on 'a or '' map Y y$ " so Y is analagous to C and D map  ddu " single-line redraw map  :n +/ " go to next file in arg list, same position " useful for "vi +/string file1 file2 file3" " " " META MACROS, all begin with meta-key '\' ; more later in file " map  \ " so can use both ^I and \ for meta-key " map \/ dePo/\<pA\>"wdd@w " find current word, uses w buffer " map \C ok:co. :s/./ /g o80a :-1s;^;:s/; :s;$;//; "mdd@m:s/\(.\)./\1/g :s;^;:-1s/^/; "mdd@mjdd " center text. there's a better way, but i lost the short version. " " INVERT CASE ON WORDS -- V is like W, v is like w. 3V is fine, but only to EOL. " uses both register n and mark n. map \v ywmnoP:s/./\~/g 0"nDdd`n@n " abc -> ABC ABC->abc map \V yWmnoP:s/./\~/g 0"nDdd`n@n " abc.xyz -> ABC.XYZ ABC.XYZ->abc.xyz " " " EXECUTION MACROS -- these two are for executing existing lines. " map \@ "mdd@m " xqt line as a straight vi command (buffer m, use @@ to repeat) map \! 0i:r!"ndd@n " xqt line as :r! command (buffer n, use @@ to repeat) " map \t :r!cat /dev/tty " read in stuff from X put buffer " " c-hacking exrc source, useful on c programs et al, but not text " set tags=tags\ /mnt/tchrist/tmptags\ /usr/lib/tags " /tmp/tags is so can make tmp tag file of r/o src dirs " by "set d = $cwd;cd;ctags -twd $d/*.[ch];mv tags tmptags;cd $d' " " " BLOCK MACROS -- these help when dealing with C blocks " map!  { } O " this will begin a block, leaving in insert mode map!  /} a " and this will take you past its end, leaving in insert mode " " " " LINT MACRO. deletes all text from "lint output:" and below, (if any) " replacing it with lint output in pretty block comment form. could " do sed work myself, but this is faster. " " the map! is for subsequent map, not by people, " tho /^Lo would make sense. " this is one of those famous time/space tradeoffs " map! o lint output " " and now for the real work map \l Go /* o / o dG:w o/*** o<<:r!lint -u -lc %|sed 's/^/ * /' Go***/N " " indent this for me " map \i :%!indent -i4 " " COMMENTING MACROS -- these are actually pretty amazing " " from edit mode, this comments a line map  ^i/* A */^ " " and this undoes it map  :s/\/\* \([^*]*\) \*\//\1 " " this next one defeats vi's tail-recursion defeatism " called by 2 maps following this one map!  :unmap!   " " while in insert mode, this will put you "inside" a comment map!  :map!  aoa /* */hhi " " while in edit mode, this begins a block comment -- ^N to escape map \c O/* * */k:map!   * A " " and this is for adding more lines to a block comment -- ^N to escape map \o :map!   * A " " " this stuff (probably) only works with UW vi. commented out. " "set tagstack " so we can :tag and :pop deeper than 1 level "set filestack " so we can tag lookup on files and pop off "set path=/mnt/tchrist " so we can say "vi foo" or ":n foo" and look all those places " if the file is relative and not in . "set ?S1200:window=8 " if (speed==1200) set window=8 " cause the default is too much. "set ?Tcitc:fastfg " if (term==citc) set fastfg " " c-hacking exrc source that only works with UW vi " "set tagprefix " allows abbreviated tags. better than std taglength " " " things i want active when editing text not programs " set ignorecase " cause this is test set wrapmargin=5 " this sets autowrap 5 from right margin " " map _ i_ll " this character will now be underlined when less'd, rn'd, etc. " " SPELL MACROS " map \s :w go:$r!spell % " spell the file, placing errors at bottom, use \w to find map \n Gdd\/ " for find next spelling error " " " FORMATING MACROS " map \P :.,$!fmt -75 " format thru end of document map \p !}fmt -75 " format paragraph map \f 1G/--- j:.,$!fmt -75 " format message map \e :%!expand -4 " expand tabs to 4 stops " map \r 1G/^-/:r!sed -e '1,/^$/d' -e 's/^./> &/' $editalt /^-/jma " read in @, quoted (for MH replies, who link @ to current file) map \d :s/$/ $/ $r 74|?  s $xx0 " " ab CCC CONVEX Computer Corporation ab ccc convex computer corporation ab Chr Christiansen ab Dec December ab dec december ab Feb February ab feb february ab Fri Friday ab fri friday ab Int International ab info information ab Jan January ab jan january ab Mon Monday ab mon monday ab nite night ab Nov November ab nov november ab Oct October ab oct october ab rrt Return-Receipt-To: tchrist " for mail ab Sat Saturday ab Sep September ab sep september ab tho though ab thru through ab Thu Thursday ab thu thursday ab thur thursday ab tonite tonight ab Tue Tuesday ab tue tuesday ab univ university ab Wed Wednesday ab wed wednesday ab WI Wisconsin ab WI Wisconsin ab Wi Wisconsin ab wi wisconsin ab wi wisconsin ab Xmas Christmas ab xmas christmas ab covnex convex ab Covnex Convex ab versino version ab att AT&T " " $Source: /tac/tchrist/src/exrc/RCS/common.uw,v $ " $Revision: 1.3 $ " $Date: 88/04/10 18:16:15 $ " " this stuff (probably) only works with UW vi. " "set tagstack " so we can :tag and :pop deeper than 1 level "set filestack " so we can tag lookup on files and pop off "set path=/tac/tchrist\ /etc\ /usr/include\ /usr/include/sys " so we can say "vi foo" or ":n foo" and look all those places " if the file is relative and not in . "set ?S1200:window=6 " if (speed==1200) set window=8 " cause the default is too much. "set ?Tcitc:fastfg " if (term==citc) set fastfg " " stuff for text editing that will only work with UW vi " " set up wrapmargin as 75 columns, thus letting me be quoted " this is so dumb. wrapmargin should be absolute not relative " "set ?W80:wrapmargin=5 "set ?W132:wrapmargin=47 "set ?W98:wrapmargin=23 "map \a :1,/^-*$/s/@\([^ ][^ ]*\)/%\1@hydra/g "map! `  set modelines " so that we spot lines like /* vi:set tabstops=3 */ " at the top of a file, kinda like file-specific exrc commands. " considered evil. don't do this as root. " map # :s/$/ $/ $r 74|F s $xx0 "map # J:s/$/ $/ $r 74|F s $xx0j " " for when terminals have the damn escape key in the wrong place "map! `