diff options
| author | Teddy Wing | 2015-10-05 08:43:26 -0400 |
|---|---|---|
| committer | Teddy Wing | 2015-10-05 08:43:26 -0400 |
| commit | f37fb0a02a4fe9185c3e9cbe82b234d12fbb0c72 (patch) | |
| tree | 1610b4214312bbe12863b5738067f20b12cc00ab | |
| parent | 2c506d28dccb0df69cb7da24c81555594211246d (diff) | |
| download | vim-space-vlaze-f37fb0a02a4fe9185c3e9cbe82b234d12fbb0c72.tar.bz2 | |
Add random.vim
Add a random number generator based on this Stack Exchange post from
Carpetsmoker:
http://vi.stackexchange.com/questions/807/how-to-generate-random-numbers/812#812
Since Vimscript doesn't have a random number generator, shell out to
Python and get a random int between 0 and the max value passed in.
| -rw-r--r-- | autoload/space_vlaze/random.vim | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/autoload/space_vlaze/random.vim b/autoload/space_vlaze/random.vim new file mode 100644 index 0000000..b3b151e --- /dev/null +++ b/autoload/space_vlaze/random.vim @@ -0,0 +1,7 @@ +" Generate a random integer between 0 and `max` +" +" From: +" http://vi.stackexchange.com/questions/807/how-to-generate-random-numbers/812#812 +function! space_vlaze#random#Random(max) + return system('python -c "import random; print(random.randint(0, ' . a:max . '))"') +endfunction |
