On Fri, Apr 21, 2006 at 01:41:46AM +0200, Nikolai Weibull wrote: > > I would be able to define my long-wanted "g:" > mapping that makes : act like an operator, i.e., first waits for a > range and then starts command mode with that range on the command > line: > > noremap <silent> g: <Esc>:set operatorfunc=GetCommandModeRange<CR>g@ > [snip] > I can't put the :...-stuff after the g@, as Vim will just eat them up > for the g@ command. > > Perhaps I'm missing something, but I don't think so. There's simply > no way to do what I want. > > If anyone has a hack to enable me to do this, please share it with me.
You *can* add the range '[,'] at the end of the mapping if you use inputsave() and inputrestore(). The following example uses g@ with a dummy function to set these two marks. If you use the GetMotion() function from foo.vim http://www.vim.org/script.php?script_id=72 (my file of example vim functions) then you do not have to hit <CR> after entering your motion. It is not entirely smooth, and adding "silent" does not help much, but please tinker. HTH --Benji Fisher fun! Dummy(mode) endfun fun! Gat() call inputsave() " silent let mtn = GetMotion("") let mtn = input("motion: ") call inputrestore() set operatorfunc=Dummy execute "normal g@" . mtn endfun map g: :call Gat()<CR>:'[,']