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>")
On Nov 11, 8:41 am, StarWing <[EMAIL PROTECTED]> wrote:
> maybe you could write a function to do it.
>
> On 11月11日, 上午9时14分, Gary Johnson <[EMAIL PROTECTED]> wrote:
>
> > 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
>
> > Regards,
> > Gary
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---