I really, really don't like the way mappings work in Vim. They're too
much in between being something that executes a command and something
that just sends keys. And the separation between user-defined
mappings and commands associated with a given ascii character has
always felt like a very poor design choice.
Still, I figured that now that we have operator functions and
expression mappings (that don't seem to be able to do anything that
<C-R>=... couldn't do) 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@
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? It's just not possible.
It seems that we lack a function to just send a set of keystrokes to
Vim and Vim will take the appropriate action.
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.
Thanks.
nikolai
--
Mood: tired, angry, frustrated
Threats made to my life to date: 2 (+1 since yesterday)
Threat-to-mood correlation: .5
Quote du jour: "Hell is other people." -- Jean-Paul Sartre