From aec3ecc838766701ae8e7df48c2a0b403d82b364 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Mon, 11 Nov 2019 20:09:43 -0800 Subject: [PATCH] add command for guids --- .vim/functions.vim | 16 ++++++++++++++++ .vim/keymaps.vim | 3 +++ 2 files changed, 19 insertions(+) diff --git a/.vim/functions.vim b/.vim/functions.vim index 6c56275..83313b3 100644 --- a/.vim/functions.vim +++ b/.vim/functions.vim @@ -9,3 +9,19 @@ function! s:unalign() range endfunction command! -range UnAlign ,call s:unalign() + +function! s:guid() + if has('pythonx') + pythonx import uuid + let l:guid = pyxeval('str(uuid.uuid4())') + elseif has('windows') + let l:guid = system('powershell.exe -command "[guid]::NewGuid().ToString()"') + endif + if exists('l:guid') + execute 'normal! a' . l:guid . "\" + else + echoerr 'No GUID provider available' + endif +endfunction + +command! Guid call s:guid() diff --git a/.vim/keymaps.vim b/.vim/keymaps.vim index b7330e1..da34a77 100644 --- a/.vim/keymaps.vim +++ b/.vim/keymaps.vim @@ -35,6 +35,9 @@ nnoremap l nnoremap j gj nnoremap k gk +" functions +nnoremap g :Guid + " fzf nnoremap fg :GFiles nnoremap ff :Files ~