Re: Mappings fail me, yet again

2006-04-24 Thread Benji Fisher
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=GetCommandModeRangeCRg@
 
[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:'[,']


Re: Mappings fail me, yet again

2006-04-21 Thread Nikolai Weibull
On 4/21/06, sean [EMAIL PROTECTED] wrote:
 On Fri, 21 Apr 2006 10:05:18 +0200
 Nikolai Weibull [EMAIL PROTECTED] wrote:

  How do you define the region to be from the current line to the last
  line?  You can't press G.  All you can give is a number prefix.  Or
  perhaps there's some command I've missed?

 G works here,   VG:deleteenter   deletes everything from the current
 line down to and including the last line of the file.   Is  VG:  good
 enough for what you want?

I guess I should have put , without starting visual mode at the end
of the first sentence.

 Also, you can type it manually:
[...]

I'm not dumb.

 nikolai


Re: Mappings fail me, yet again

2006-04-20 Thread Yakov Lerner
On 4/21/06, Nikolai Weibull [EMAIL PROTECTED] wrote:
 Still, I figured that now that we have operator functions ...
 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=GetCommandModeRangeCRg@

 function! GetCommandModeRange(type)
   let b = line('[)
   let e = line('])

   if b  e
 let range = '.,+' . (e - b)
   elseif b == e
 let range = '.'
   else
 let range = '.,+' . (b - e)
   endif

start command mode with 'range' already on the command line
   ...
 endfunction

 The question is, how do I start command mode?

Does this work for you inside the function :
:exe normal :.range
?

Yakov