home *** CD-ROM | disk | FTP | other *** search
/ ftp.cse.unsw.edu.au / 2014.06.ftp.cse.unsw.edu.au.tar / ftp.cse.unsw.edu.au / pub / doc / editors / macro-tips < prev    next >
Encoding:
Text File  |  1992-10-18  |  1.0 KB  |  27 lines

  1. Vi macro management:
  2. - if possible don't repeat character sequences in different macros, put them
  3.   in their own macros;
  4. - try to be concise, e.g. instead of "map @i :set noautoindent^V^M" use
  5.   "map @i :se noai^V^M";
  6. - don't try to solve difficult problems in vi, create appropriate shell
  7.   scripts instead, to be invoked through maps;
  8. - create specialized macro files, to be sourced only when appropriate,
  9.   you don't need all your maps all the time, e.g. "map ^C :!cc % " isn't
  10.   that useful when editing a letter to your friend; you might even create
  11.   shell scripts to do the sourcing for you -
  12.  
  13.     % cat ~/bin/cvi
  14.     #!/bin/sh
  15.     /usr/ucb/vi +"so $HOME/.cmaps" ${1+"$@"}
  16.     %
  17.  
  18. However, this script reveals an interesting bug: the source command will only
  19. take place when the first EXISTENT file is read into the buffer!
  20. A better idea than hacking the shell script is to define a standard macro
  21. (in EXINIT) to source ~/.cmaps:
  22.  
  23.     map\C :unm\C^V|so~/.cmaps^M
  24.  
  25. No unnecessary spaces! :-)
  26. When ~/.cmaps has been sourced, the `\C' macro can be deleted, hence the `unm'.
  27.