home *** CD-ROM | disk | FTP | other *** search
/ The UNIX CD Bookshelf / OREILLY_TUCB_UNIX_CD.iso / upt / examples / LINUX / ARCHIVE / EXRC.Z / EXRC / sbin / exrc
Encoding:
Text File  |  1993-01-01  |  6.7 KB  |  275 lines

  1. "" COPY THIS FILE INTO $HOME/.exrc, uncomment what you need.
  2. ""
  3. ""
  4. "" Filter through maps
  5. ""
  6. "" Map the F4 key during command mode to set the noautowrite opetion
  7. "" (:se aw), write the buffer to your file (:w), delete all lines in the
  8. "" buffer (:%d), and start a shell command line (:r !).
  9. "map #4 :se noaw
  10. :w
  11. :%d
  12. :r !
  13. ""
  14. "" Put a space between the command line you type and the filename (^V ),
  15. "" output the current filename followed by a return to execute the
  16. "" command (%^M), delete the blank line generated by reading the Unix
  17. "" command (:1d), and turn on the autowrite option again (:se aw).
  18. "map! #4  '%'
  19. :1d:se aw
  20. ""
  21. ""
  22. "" Abbreviations to "cut and paste" between vi sessions using temporary files.
  23. ""
  24. "" Write to a temporary file
  25. "ab aW w! /tmp/jerry.temp.a
  26. "" Insert contents of temporary file
  27. "ab aR r /tmp/jerry.temp.a
  28. "ab bW w! /tmp/jerry.temp.b
  29. "ab bR r /tmp/jerry.temp.b
  30. ""
  31. ""
  32. "" Maps for pasting
  33. ""
  34. "" Set 'exact' input mode for pasting exactly what is entered:
  35. "map!  :se noai wm=0a
  36. "" Set 'normal' input mode with usual autoindent and wrapmargn:
  37. "map!  :se ai wm=8a
  38. "" Read pasted text, clean up lines with fmt.  Type CTRL-D when done:
  39. "map!  :r!fmt
  40. ""
  41. ""
  42. ""    INPUT MACROS that to have active
  43. ""
  44. "map!  :stop
  45. ""    so i can stop in input mode.  note that autowrite is set, so 
  46. "map!  :stop!
  47. ""    will stop me without writing.
  48. ""
  49. "map!   O
  50. ""    lets me do kindof a negative carriage return in input mode.
  51. "map!  bi
  52. ""    non-destructive ^W
  53. "map!  Ea
  54. ""    and its inverse
  55. ""
  56. ""    EMACS Style ARROW MACROS
  57. ""
  58. "map!  i
  59. "map!  lli
  60. "map!  I
  61. "map!  A
  62. ""
  63. ""
  64. ""    EXCHANGE MACROS -- for exchanging things
  65. ""
  66. "map v xp
  67. ""    exchange current char with next one in edit mode
  68. "map V :m+1
  69. ""    exchange current line with next one in edit mode
  70. "map!   hxpa
  71. ""    exchange last typed char with penultimate one in insert mode
  72. "map = 
  73. ""    edit previously editted file
  74. ""
  75. ""    OTHER MACROS
  76. ""
  77. "map  :w
  78. ""    write out the file
  79. ""
  80. "map * i
  81. ""    split line
  82. ""
  83. "map  :stop!
  84. ""    unconditional stop
  85. "map Y y$
  86. ""    so Y is analagous to C and D
  87. "map  ddu
  88. ""    single-line redraw
  89. "map  :n +/
  90. ""    go to next file in arg list, same position 
  91. ""    useful for "vi +/string file1 file2 file3"
  92. ""
  93. ""
  94. ""    META MACROS, all begin with meta-key '\' ; more later in file
  95. ""
  96. "map      \
  97. ""    so can use both ^I and \ for meta-key
  98. ""
  99. "map \/ dePo/\< pA\> "wdd@w
  100. ""    find current word, uses w buffer
  101. ""
  102. "map \C o k:co. 
  103. :s/./ /g
  104. oa :-1s;^;:s/;
  105. :s;$;//;
  106. "mdd@m:s/\(.\)./\1/g
  107. :s;^;:-1s/^/;
  108. "mdd@mjdd
  109. ""    center text.  there's a better way, but i lost the short version.
  110. ""
  111. ""    INVERT CASE ON WORDS -- V is like W, v is like w.  3V is fine, but only to EOL.
  112. ""    uses both register n and mark n.
  113. "map \v ywmnoP:s/./\~/g
  114. 0"nDdd`n@n
  115. ""    abc -> ABC    ABC->abc
  116. "map \V yWmnoP:s/./\~/g
  117. 0"nDdd`n@n
  118. ""    abc.xyz -> ABC.XYZ    ABC.XYZ->abc.xyz
  119. ""
  120. ""
  121. ""    EXECUTION MACROS --    these two are for executing existing lines.  
  122. ""
  123. "map \@ "mdd@m
  124. ""    xqt line as a straight vi command (buffer m, use @@ to repeat)
  125. "map \! 0i:r!"ndd@n
  126. ""    xqt line as :r! command (buffer n, use @@ to repeat)
  127. ""
  128. "map \t :r!cat /dev/tty
  129. ""    read in stuff from X put buffer [in X window system --JP]
  130. ""    
  131. ""
  132. ""    BLOCK MACROS -- these help when dealing with C blocks
  133. ""
  134. "map!  {
  135. } O
  136. ""    this will begin a block, leaving in insert mode
  137. "map!  /}
  138. a
  139. ""    and this  will take you past its end, leaving in insert mode
  140. ""
  141. ""
  142. ""
  143. ""    LINT MACRO.  deletes all text from "lint output:" and below, (if any)
  144. ""    replacing it with lint output in pretty block comment form.  could
  145. ""    do sed work myself, but this is faster.  
  146. ""
  147. ""    the map! is for subsequent map, not by people, 
  148. ""    though /^Lo would make sense.
  149. ""    this is one of those famous time/space tradeoffs 
  150. ""
  151. "map!  o lint output
  152. ""
  153. ""    and now for the real work
  154. "map \l Go
  155. /*  o
  156. / o
  157. dG:w
  158. o/***  o<<:r!lint -u -lc %|sed 's/^/ *  /'
  159. Go***/N
  160. ""
  161. ""    indent this for me
  162. ""
  163. "map \i :%!indent -i4
  164. ""
  165. ""    COMMENTING MACROS -- these are actually pretty amazing
  166. ""
  167. ""    from edit mode, this comments a line
  168. "map      /* A */^
  169. ""
  170. ""    and this undoes it
  171. "map  :s/\/\* \([^*]*\) \*\//\1
  172. ""
  173. ""    this next one defeats vi's tail-recursion defeatism
  174. ""    called by 2 maps following this one 
  175. "map!  :unmap! 
  176. ""
  177. ""    while in insert mode, this will put you "inside" a comment
  178. "map!  :map! 
  179.  aoa /*  */hhi
  180. ""
  181. ""    while in edit mode, this begins a block comment -- ^N to escape
  182. "map \c    O/*
  183.  *  
  184. */k:map! 
  185.  
  186. *  
  187. A
  188. ""
  189. ""    and this is for adding more lines to a block comment -- ^N to escape
  190. "map \    :map! 
  191.  
  192. *  
  193. A
  194. ""
  195. ""
  196. "map _ i_ll
  197. ""    this character will now be underlined when less'd, rn'd, etc.
  198. ""
  199. ""    SPELL MACROS
  200. ""
  201. "map \s :w
  202. go:$r!spell %
  203. ""    spell the file, placing errors at bottom, use \w to find
  204. "map \n Gdd\/
  205. ""    for find next spelling error
  206. ""
  207. ""
  208. ""    FORMATING MACROS
  209. ""
  210. "map \P :.,$!fmt -75
  211. ""    format thru end of document
  212. "map \p !}fmt -75
  213. ""    format paragraph
  214. "map \f 1G/---
  215. :.,$!fmt -75
  216. ""    format message (assumes MH Mail "comp" format)
  217. "map \e :%!expand -4
  218. ""    expand tabs to 4 stops
  219. ""
  220. "map \r 1G/^-/:r!sed -e '1,/^$/d' -e 's/^./> &/' @ /^-/j
  221. ""    read in @, quoted (for MH replies, who link @ to current file)
  222. "map \d :s/$/ $/
  223. $r 74|? 
  224. s
  225. $xx0
  226. ""    split line, like !!fmt but cheaper
  227. ""
  228. ""
  229. "ab Jan January
  230. "ab jan january 
  231. "ab Feb February
  232. "ab feb february
  233. "ab Sep September
  234. "ab sep september
  235. "ab Oct October
  236. "ab oct october
  237. "ab Nov November
  238. "ab nov november
  239. "ab Dec December
  240. "ab dec december
  241. "ab Xmas Christmas
  242. "ab xmas christmas
  243. "ab Mon Monday
  244. "ab mon monday
  245. "ab Tue Tuesday
  246. "ab tue tuesday
  247. "ab Wed Wednesday
  248. "ab wed wednesday
  249. "ab Thu Thursday
  250. "ab thu thursday
  251. "ab Fri Friday
  252. "ab fri friday
  253. "ab Sat Saturday
  254. "ab Sun Sunday
  255. "ab Int International
  256. "ab info information
  257. ""
  258. ""
  259. "" Map ctrl-h, ctrl-j, ctrl-k and ctrl-l to to move the cursor during
  260. "" test-input mode, just as the commands h, j, k, and l do in command mode.
  261. "map!  i
  262. "map!   ka
  263. "map!   la
  264. "map! 
  265. " ja
  266. "" Note: the two lines above map ^J (LINEFEED)
  267. ""
  268. ""
  269. "" For VT100 Terminals
  270. ""
  271. "set ai redraw sm wm=1
  272. "set tabstop=4
  273. "set shiftwidth=4
  274. "" great for auto indenting { } pairs.
  275. "map! {} {
  276. }O     
  277. "" cursor down while inserting
  278. "map! OD ha
  279. "" vt100 up arrow while inserting
  280. "map! OA ka
  281. "" cursor left while inserting
  282. "map! OB ja
  283. "" cursor right
  284. "map! OC la
  285. "" mapped pf1 to append to end of line
  286. "map  OP A
  287. "" insert mode of the above
  288. "map! OP A 
  289. "" mapped pf2 to insert before line
  290. "map  OQ 0i
  291. "" insert mode of the above
  292. "map! OQ i
  293. "" troff left quote
  294. "map! ``  \*(lq 
  295. "" troff right quote
  296. "map! ''  \*(rq
  297. ""
  298. ""
  299. "" Maps for cutting (Kut) the current line by replacing a space with a
  300. "" carriage return at or before the 78th character.
  301. ""
  302. "" Uncomment one or the other; the first one doesn't seem to work on
  303. "" some versions of vi.
  304. ""
  305. "" This one uses | to move to column 78
  306. "map K 78|lBhr
  307. "" This one counts tabs as single characters
  308. ""map K 078lF r
  309.