Monday, December 28, 2009

Re: when to use or in mappings

On Mon, Dec 28, 2009 at 9:01 AM, Tim Chase wrote:
>> <Esc>  or CTRL-[ End insert or Replace mode, go back to Normal mode.
>>                  Finish abbreviation.
>>
>> CTRL-C Quit insert mode, go back to Normal mode.
>>         Do not check for abbreviations.
>>         Does not trigger the |InsertLeave| autocommand event.
>>
>> In mappings I have seen both used.
>>
>> Please elaborate the fine points of use.
>
> Well, the help summarizes the differences fairly succinctly:  do you
> want abbreviations to be expanded or not?  Do you want the InsertLeave
> autocommand event to trigger.  According to the help, it looks like
> abbreviations can get expanded in mappings[1] but I didn't get them to
> trigger in my testing:
>
>   :iab x hello
>   :nnoremap Q oa x b<esc>
>
> and then using Q to insert the text, I just get a line with "a x b"
> instead of "a hello b".

Try using :nmap instead of :nnoremap.

:iab x hello
:nmap W oa x b<esc>

I don't know if this is explicitly documented anywhere, but it makes
sense when you think about it: if the purpose of noremap'ing is to
make sure that your map always behaves the same way, it makes sense
that it would disable both maps and abbreviations.

~Matt

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php

No comments: