Skip to content

Instantly share code, notes, and snippets.

@cohama
Last active December 29, 2015 06:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cohama/7629492 to your computer and use it in GitHub Desktop.
Save cohama/7629492 to your computer and use it in GitHub Desktop.
Vim script でランダム文字列生成
let s:V = vital#of('r')
let s:Xor = s:V.import('Random.Xor128')
function! s:randomString(char_kind, length)
let rand_str = ''
for i in range(a:length)
let rand_char = a:char_kind[abs(s:Xor.rand()) % len(a:char_kind)]
let rand_str .= rand_char
endfor
return rand_str
endfunction
let s:ascii_kinds = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&''()-=^~\|@`[{;+:*}},<.>/?_'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment