On 12/11/08 12:01, Andy Wokula wrote:
> Gary Johnson schrieb:
>> On 2008-11-10, Pento<[EMAIL PROTECTED]> wrote:
>>> Hello, everybody!
>>>
>>> Now for map shortcut for example for :ls in 3 modes I need to add 3
>>> lines to my ~/.vimrc:
>>>
>>> " F5 - show buffers
>>> nmap<F5> :ls<cr>:b
>>> imap<F5> <esc>:ls<cr>:b
>>> vmap<F5> <esc>:ls<cr>:b
>>>
>>> How can I do this in one line?
>> Here's one way:
>>
>> exe 'nmap<F5> :ls<cr>:b' | exe 'imap<F5> <esc>:ls<cr>:b' | exe
>> 'vmap<F5> <esc>:ls<cr>:b'
>>
>> Or, if you want to avoid repeating the ":ls<cr>:b" portion each
>> time:
>>
>> exe 'nmap<F5> :ls<cr>:b' | exe 'imap<F5> <esc><F5>' | exe 'vmap<F5>
>> <esc><F5>'
>>
>> See
>>
>> :help :|
>> :help :execute
>
> The example does not require :exe
>
> :nmap<F5> :ls<cr>:b |imap<F5> <esc>:ls<cr>:b |vmap<F5> <esc>:ls<cr>:b
>
> you can reuse the key that's already mapped
> :nmap<F5> :ls<cr>:b |imap<F5> <esc><F5>|vmap<F5> <esc><F5>
> :nn<F5> :ls<cr>:b |imap<F5> <esc><F5>|vmap<F5> <esc><F5>
>
However, without ":exe", the space before the bar will be included in
the {rhs} of your mapping. You may or may not want that... OTOH, if you
want a space at the end of the {rhs} of the last mapping on the line,
you should replace it by <Space> to make it more legible when you read
these mappings again next year.
Best regards,
Tony.
--
One learns to itch where one can scratch.
-- Ernest Bramah
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---