On 6/13/2011 11:43 PM, ZyX wrote:
Reply to message «for statement with character classes»,
sent 05:52:36 14 June 2011, Tuesday
by David Fishburn:

No, there are no such shortcuts. Nearly equivalent:

     for letter in map(range(char2nr('0'), char2nr('9'))+
                      \range(char2nr('a'), char2nr('z'))+
                      \range(char2nr('A'), char2nr('Z')), 'nr2char(v:val)')
         ...
     endfor
I would say that is a pretty good short cut and exactly what I needed.
Why do you need this?

For the YankRing plugin (http://www.vim.org/scripts/script.php?script_id=1234) I want to optionally display all the numbered and lettered registers in the window and allow the user to choose from those as well. The FOR statement allows me to easily iterate through the registers and display them.

Something like this:

    for letter in map(range(char2nr('0'), char2nr('9'))+
                     \range(char2nr('A'), char2nr('Z')), 'nr2char(v:val)')
        YRDisplayElem(letter, getreg(letter) )
    endfor

I never remember the map() function, but I still wouldn't have come up with the char2nr stuff.

Much appreciated.

Dave

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

Reply via email to