Path: utzoo!news-server.csri.toronto.edu!rutgers!usc!samsung!uunet!mcsun!ukc!slxsys!ibmpcug!dylan From: dylan@ibmpcug.co.uk (Matthew Farwell) Newsgroups: comp.editors Subject: Re: vi mapping difficulty Message-ID: <1991Mar12.122340.9153@ibmpcug.co.uk> Date: 12 Mar 91 12:23:40 GMT References: <1991Mar08.205940.11108@vpnet.chi.il.us> Reply-To: dylan@ibmpcug.CO.UK (Matthew Farwell) Organization: The IBM PC User Group, UK. Lines: 47 In article <1991Mar08.205940.11108@vpnet.chi.il.us> dattier@vpnet.chi.il.us (David W. Tamkin) writes: >I want to clear out any lines that don't have text on them. The purpose is >to separate paragraphs in quoted text. > >So I have this in my .exrc: > >map ^X :v/[0-9A-Za-z]/s/.*//^M > >where ^X and ^M are ctrl-X and CR. The ^X doesn't need a ^V to be entered, >but with or without it, or mapped to a printing character, the results are >the same. > >Now, on some systems I call the mapping works fine. On all of them, if I >type the command in, it works. But on other systems (including those I call >most), if I try to use a mapping and call it by rebound key, these are the >effects: > >If I've just read the file into the buffer and made no changes yet, it works. >Otherwise, one or two occurrences of the pattern get replaced and the >operation stops with "Can't undo in global" -- so who asked for an undo? > >It's not a matter of the "modified" flag, because if I do :w or :w! to write >the buffer out and remove the flag, the operation (if called from a rebound >key) still aborts with "Can't undo in global." If I :w and then :e %, it >will work if I use it before making any more changes. > >Short of expecting the system administrators to install new versions of vi, >is there any way I can change the mapping to make it function? Binding >:g/^[^0-9A-Za-z]*$/s///^M to a key acts the same way. I had a similar problem to this. My mapping was map ^W 1G:1,/^$/g/: $/d^M Where ^W is ctrl-W and ^M is ctrl-M. (This removes all blank headers when you're entering a news article) This works fine when you type it in. It even works when its a macro, but it beeps at me. I can undo it, but then it doesn't work. Anyone got any ideas? (Other than this, my problem is similar to above) Dylan. -- Matthew J Farwell: dylan@ibmpcug.co.uk || ...!uunet!ukc!ibmpcug!dylan If you've ever wondered how to get triangles from a cow, you need butter, milk and cheese and an equilateral chainsaw.