Saturday, February 5, 2011

Re: ctrl-o with a mapping

Am 05.02.2011 17:38, schrieb Ben Fritz:
> On Feb 5, 4:05 am, ZyX<zyx....@gmail.com> wrote:
>> Reply to message «Re: ctrl-o with a mapping»,
>> sent 23:56:30 05 February 2011, Saturday
>> by AK:
>>
>>> Well, this is a normal mode mapping (nnoremap), by definition all of
>>> its contents should run under normal mode or not at all.
>>
>> The fact that it is normal mode mapping means that {lhs} will be
>> replaced by {rhs} if you type {lhs} in normal mode. It never meant
>> that it should run under normal mode, the fact that first command is
>> run under normal mode is just a consequence of the fact that you
>> press {lhs} in normal mode.
>
> It seems strange to me that recorded macros behave differently from
> normal mode mappings, especially if you interpret them as above. :help
> @ even says
>
> "the register is executed like a mapping".

I think this was only mentioned in contrast to typing all the keys at
the keyboard:
:h feedkeys()
:h 'wildchar'
:h c_<Esc>

etc. (btw, is there a complete list of differences)?
It doesn't say that macros and mappings are equivalent.

> For example:
>
> qa0:echo getfontname()<Enter>q
> i<C-O>@a
>
> This does not insert the :echo getfontname(), it does exactly as is
> done in normal mode.
>
> However,
>
> :nnoremap<F9> 0:echo getfontname()<CR>
> i<C-O><F9>
>
> This inserts the :echo command in the text.

i_CTRL-O executes one Normal mode (builtin) command, then returns to
Insert mode. @a is a Normal mode command, but <F9> is not (same for any
other remapped sequence). Also, @a accepts a count, but <F9> doesn't.

--
Andy

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: