home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / editors / 3147 < prev    next >
Encoding:
Internet Message Format  |  1993-01-05  |  2.3 KB

  1. Path: sparky!uunet!pipex!bnr.co.uk!uknet!mcsun!sun4nl!sci.kun.nl!cs.kun.nl!hansm
  2. From: hansm@cs.kun.nl (Hans Mulder)
  3. Newsgroups: comp.editors
  4. Subject: Re: VI Macros, Or What Is Really Going On Here?
  5. Message-ID: <C0DosB.4tz@sci.kun.nl>
  6. Date: 5 Jan 93 11:19:22 GMT
  7. References: <1992Dec30.182744.9053@telesciences.com>
  8. Sender: news@sci.kun.nl (News owner)
  9. Organization: University of Nijmegen, The Netherlands
  10. Lines: 71
  11. Nntp-Posting-Host: zeus.cs.kun.nl
  12.  
  13. In <1992Dec30.182744.9053@telesciences.com> ciacovel@telesciences.com (Chris D Iacovelli) writes:
  14.  
  15. >Dear VI users,
  16.  
  17. >I have one macro which centers text lines,
  18. > i.e.
  19. >map [c :s/^[ ^I]*//^M$maKV{{\q
  20. >          ||       ||
  21. >          ||       A ^V'ed ^M
  22. >          ||
  23. >          Not a ^V'ed ESC
  24.  
  25. >I have another macro to stop formatting comments a la c-style,
  26. >i.e.
  27. >map! */ ^[:so ~/.CCOM.OFF^["ap$s/ ^[A
  28. >        ||               ||       ||
  29. >        ==============|=============
  30. >                ^V'ed ESC's
  31.  
  32. >The above macros work fine if they are in seperate .exrc files.
  33. >However, when they are incorporated into the same .exrc file they don't
  34. >work,
  35. > i.e. when I execute the [c macro the */ macro is called and I get an
  36. >      ":input read error".
  37.  
  38. >I believe that the */ of the search string in the [c macro is being
  39. >replaced with the contents of the */ map.
  40.  
  41. >Does this mean that during command mode that VI actually is in single
  42. >line insert mode, insert into a command line buffer? or am I doing
  43. >something wrong in my macro defines?
  44.  
  45. Yes, that's what happens.
  46.  
  47. There are at least four things you can do about it:
  48.  
  49. 1. Insert enough control-Vs:
  50.  
  51. map [c :s/^[ ^I]^V^V*//^M$maKV{{\q
  52.           ||    ||||   ||
  53.           ||    ||||   A ^V'ed ^M
  54.           ||    ||||
  55.           ||    Type 4 control-Vs, to get two in the .exrc, to get one
  56.           ||    in the rhs of the map, to get the * properly quoted.
  57.           ||
  58.           Not a ^V'ed ESC
  59.  
  60. 2. Leave the trailing /s off the :s command:
  61.  
  62. map [c :s/^[ ^I]*^M$maKV{{\q
  63.           ||     ||
  64.           ||     A ^V'ed ^M
  65.           ||
  66.           Not a ^V'ed ESC
  67.  
  68. 3. Use another separator, e.g.+:
  69.  
  70. map [c :s+^[ ^I]*++^M$maKV{{\q
  71.           ||        ||
  72.           ||        A ^V'ed ^M
  73.           ||
  74.           Not a ^V'ed ESC
  75.  
  76. 4. Use vi mode commands:
  77.  
  78. map [c >>d0$maKV{{\q
  79.  
  80. --
  81. Hope this helps,
  82.  
  83. Hans Mulder            hansm@cs.kun.nl
  84.