home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!pipex!bnr.co.uk!uknet!mcsun!sun4nl!sci.kun.nl!cs.kun.nl!hansm
- From: hansm@cs.kun.nl (Hans Mulder)
- Newsgroups: comp.editors
- Subject: Re: VI Macros, Or What Is Really Going On Here?
- Message-ID: <C0DosB.4tz@sci.kun.nl>
- Date: 5 Jan 93 11:19:22 GMT
- References: <1992Dec30.182744.9053@telesciences.com>
- Sender: news@sci.kun.nl (News owner)
- Organization: University of Nijmegen, The Netherlands
- Lines: 71
- Nntp-Posting-Host: zeus.cs.kun.nl
-
- In <1992Dec30.182744.9053@telesciences.com> ciacovel@telesciences.com (Chris D Iacovelli) writes:
-
- >Dear VI users,
-
- >I have one macro which centers text lines,
- > i.e.
- >map [c :s/^[ ^I]*//^M$maKV{{\q
- > || ||
- > || A ^V'ed ^M
- > ||
- > Not a ^V'ed ESC
-
- >I have another macro to stop formatting comments a la c-style,
- >i.e.
- >map! */ ^[:so ~/.CCOM.OFF^["ap$s/ ^[A
- > || || ||
- > ==============|=============
- > ^V'ed ESC's
-
- >The above macros work fine if they are in seperate .exrc files.
- >However, when they are incorporated into the same .exrc file they don't
- >work,
- > i.e. when I execute the [c macro the */ macro is called and I get an
- > ":input read error".
-
- >I believe that the */ of the search string in the [c macro is being
- >replaced with the contents of the */ map.
-
- >Does this mean that during command mode that VI actually is in single
- >line insert mode, insert into a command line buffer? or am I doing
- >something wrong in my macro defines?
-
- Yes, that's what happens.
-
- There are at least four things you can do about it:
-
- 1. Insert enough control-Vs:
-
- map [c :s/^[ ^I]^V^V*//^M$maKV{{\q
- || |||| ||
- || |||| A ^V'ed ^M
- || ||||
- || Type 4 control-Vs, to get two in the .exrc, to get one
- || in the rhs of the map, to get the * properly quoted.
- ||
- Not a ^V'ed ESC
-
- 2. Leave the trailing /s off the :s command:
-
- map [c :s/^[ ^I]*^M$maKV{{\q
- || ||
- || A ^V'ed ^M
- ||
- Not a ^V'ed ESC
-
- 3. Use another separator, e.g.+:
-
- map [c :s+^[ ^I]*++^M$maKV{{\q
- || ||
- || A ^V'ed ^M
- ||
- Not a ^V'ed ESC
-
- 4. Use vi mode commands:
-
- map [c >>d0$maKV{{\q
-
- --
- Hope this helps,
-
- Hans Mulder hansm@cs.kun.nl
-