From ba1da9fe2165d6af64a8b065c9a46d82eaa159d6 Mon Sep 17 00:00:00 2001 From: vg Date: Wed, 23 May 2018 11:34:37 +0200 Subject: support both python2 and python3 --- plugin/uuid_anchor.vim | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/plugin/uuid_anchor.vim b/plugin/uuid_anchor.vim index 1e5dfdd..9da2ceb 100644 --- a/plugin/uuid_anchor.vim +++ b/plugin/uuid_anchor.vim @@ -10,6 +10,31 @@ if exists("g:loaded_uuid_anchor_ftplugin") endif let loaded_uuid_anchor_ftplugin = 1 +if has('python') +" python2 is available +function! CreateAnchorUUID() +python << EOF +import vim +import random +generated_uuid = '{:08X}'.format(random.randint(0,256**4)) +vim.current.line += generated_uuid +vim.command(''' normal l"uye ''') +EOF +endfunction +elseif has('python3') +" python3 is available +function! CreateAnchorUUID() +python3 << EOF +import vim +import random +generated_uuid = '{:08X}'.format(random.randint(0,256**4)) +vim.current.line += generated_uuid +vim.command(''' normal l"uye ''') +EOF +endif + + + function! CreateAnchorUUID() python << EOF import vim -- cgit v1.2.3