From vim Wed Dec 11 15:57:38 2002 From: Benji Fisher Date: Wed, 11 Dec 2002 15:57:38 +0000 To: vim Subject: Re: mapping to gR X-MARC-Message: https://marc.info/?l=vim&m=103962225820839 Steve Hall wrote: > > By default, it appears that effectively toggles normal r and > normal i (on win32, others?). However, I'd like to map it to toggle > between normal *gR* and normal i except that I think I've uncovered a > bug that prevents it. > > imap gR > > works for me (which is only the first half of the toggle), but > > imap :call Replacemode() > function! Replacemode() [snip] > " start replace mode > normal gR > else > " end replace mode > normal i > endif > endfunction > > does not. Even after removing the whole upper initialization part I am > unable to get to virtual-replace mode. Can anybody spot the error? > > Thanks once again. > > Steve Hall [ digitect(at)mindspring.com ] Neither of your :normal lines gives a "complete command" in the sense of :help :normal I would try something like this: :inoremap =ToggleMode() where the ToggleMode() function returns either "x\gR\" or "\a". Adding and then deleting the "x" solves the problem of not moving the cursor when going from Insert to VReplace mode; I am not sure what to do when going from VReplace to Insert mode. (Special cases: start of line, end of line, empty line, middle of line.) Maybe using instead of will work... HTH --Benji Fisher