Monday, March 26, 2012

Re: A function to display all Functional keys F1 ~ F12

On 10:04 Mon 26 Mar , Charles Campbell wrote:
> Marcin Szamotulski wrote:
> > On 17:51 Mon 26 Mar , stardiviner wrote:
> >
> >> Sometimes I will forget which functional key do what in script map.
> >> So I want a function to display all functional keys from F1 to F12.
> >> The maps content can from command :verbose map<F1>.
> >> Those content can be displayed in any style, like a new window, or same buffer with :echomsg.
> >> I just want to display those key binds detail at once.
> >> I do not case how you archive this function. (maybe the the better the more simple it is).
> >>
> >> Thanks guys.
> >> --
> >> [stardiviner]<fuck you, world!> GPG key ID: 47C32433
> >> IRC(freeenode): Evanescence Twitter: @numbchild
> >> Key fingerprint = 9BAA 92BC CDDD B9EF 3B36 CB99 B8C4 B8E5 47C3 2433
> >> http://stardiviner.dyndns-blog.com/author.html
> >>
> > Hi,
> >
> > Something like this might work for you:
> >
> > fun! ShowFuncKeys(bang)
> > for i in range(1,12)
> > exe (a:bang == "!" ? 'verbose' : '') . " map<F".i.">"
> > endfor
> > endfun
> > com! -bang ShowFuncKeys :call ShowFuncKeys(<q-bang>)
> >
> > :ShowFuncKeys
> > will show function keys ;) and
> > :ShowFuncKeys
> > will show where they were defined as well.
> >
> That's pretty good -- what I do is reserve [s- ctrl- a-] F12 as my
> function-help key, so that it displays a one-liner describing all mappings
> (ex. F12 -> F1:refmt F2:!hls ...)
>
> Regards,
> Chip Campbell
>
> --
> 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

I was trying to make it a bit better using the following loop:

for i in range(1,12)
redir! >= map
exe "silent ".(a:bang == "!" ? 'verbose' : '') . " map<F".i.">"
redir end
if map !~ 'No mapping found'
echomsg map
endif
endfor

But I get an error that map is not defined. However if I do:
redir! >= map
exe "silent map"
redir end
'echo map' shows exactly what it should. Any ideas why redir is not working in
the first place?

Marcin

--
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: