aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvg <vg@devys.org>2018-05-23 11:34:37 +0200
committervg <vg@devys.org>2018-05-23 11:34:37 +0200
commitba1da9fe2165d6af64a8b065c9a46d82eaa159d6 (patch)
tree86a3388e8b6691966f9bf613266d6e74429b1fca
parent3e317b7338bf5b3503ff421c008f6d55b170b4f1 (diff)
downloadvim-uuid-anchor-ba1da9fe2165d6af64a8b065c9a46d82eaa159d6.tar.gz
vim-uuid-anchor-ba1da9fe2165d6af64a8b065c9a46d82eaa159d6.tar.bz2
vim-uuid-anchor-ba1da9fe2165d6af64a8b065c9a46d82eaa159d6.zip
support both python2 and python3
-rw-r--r--plugin/uuid_anchor.vim25
1 files changed, 25 insertions, 0 deletions
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