On Tue, Nov 11, 2008 at 21:29, sc <[EMAIL PROTECTED]> wrote:
> On Tuesday 11 November 2008 2:09 pm, Pento wrote:
>>
>> I wrote it! :)
>>
>> function SMap(key, action, ...)
>>     let modes = " vi"
>>     if (a:0 > 0)
>>         let modes = a:{1}
>>     endif
>>     if (match(modes, '\Ii') != -1)
>>         execute 'imap ' . a:key . ' <Esc>' . a:action
>>     endif
>>     if (match(modes, '\Nn') != -1)
>>         execute 'nmap ' . a:key . ' <Esc>' . a:action
>>     endif
>>     if (match(modes, ' ') != -1)
>>         execute 'map ' . a:key . ' <Esc>' . a:action
>>     endif
>>     if (match(modes, '\Vv') != -1)
>>         execute 'vmap ' . a:key . ' <Esc>' . a:action
>>     endif
>> endfunction
>>
>>
>> call SMap("<F3>", ":ls<cr>")
>
> but Pento:  you've written 18 lines of function to save about 4 lines in 
> .vimrc --
> seems like a net loss to me

Moreover, wanting /exactly/ the same mapping in all modes is quite
rare. There are often some slight differences, even if the same
"action" is wanted, and using <Esc> to go back first to command mode
may not always be desirable.

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

Reply via email to