Skip to content

Instantly share code, notes, and snippets.

@jonmorehouse
Created January 15, 2014 19:09
Show Gist options
  • Save jonmorehouse/8442341 to your computer and use it in GitHub Desktop.
Save jonmorehouse/8442341 to your computer and use it in GitHub Desktop.
UUID generator for vim. Inputs a uuid to copy buffer
fu! GenerateUUID()
python << EOF
import uuid
import vim
# output a uuid to the vim variable for insertion below
vim.command("let generatedUUID = \"%s\"" % str(uuid.uuid4()))
EOF
" insert the python generated uuid into the current cursor's position
:execute "normal i" . generatedUUID . ""
endfunction
"initialize the generateUUID function here and map it to a local command
noremap <Leader>r :call GenerateUUID()<CR>
@theimpostor
Copy link

Works great! FYI I had to change

python << EOF

to

py3 <<EOF

to get it to work. C.f. https://github.com/ensime/ensime-vim/issues/306#issuecomment-359591407

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment