Skip to content

Instantly share code, notes, and snippets.

@voyeg3r
Created January 28, 2018 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save voyeg3r/c8e1820127e158a47d6ba0ee619c98bd to your computer and use it in GitHub Desktop.
Save voyeg3r/c8e1820127e158a47d6ba0ee619c98bd to your computer and use it in GitHub Desktop.
This function creates a copy of any function increasing each number by one
fun! CopyAndIncrease()
try
let l:old_copy = getreg('0')
normal yip
let @0 = substitute(@0,'\d\+','\=submatch(0) + 1','g')
exec "normal }O\<Esc>p"
finally
call setreg('0', l:old_copy)
endtry
endfun
command! -nargs=0 CopyIncrease silent call CopyAndIncrease() | exec "normal \<Esc>"
let mapleader = ','
nnoremap <Leader>c :CopyIncrease<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment