Monday, May 7, 2012

RE: Expanding a range of characters

Yasuhiro MATSUMOTO wrote:
> more shorter.
>
> echo call('range', split('46-58', '-'))

Sweet. I did not know about call(). I have slightly lost track
of the original problem, but I think this might solve it:

function! ShowChars(spec)
let result = []
for item in split(a:spec, ',')
if len(item) > 1
call extend(result, map(call('range', split(item, '-')), 'nr2char(v:val)'))
else
if item == '@'
" Assume this is [A-Za-z].
call extend(result, map(range(65, 90), 'nr2char(v:val)'))
call extend(result, map(range(97, 122), 'nr2char(v:val)'))
else
call add(result, item)
endif
endif
endfor
return join(result, ', ')
endfunction

Each 'call' statement should be a single line.

After defining function, use one of following to echo or insert
a list of all the 'iskeyword' characters (which is search /\k):

:echo ShowChars(&iskeyword)
:put =ShowChars(&iskeyword)

John

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

Post a Comment