Skip to content

Instantly share code, notes, and snippets.

@Raimondi
Created November 30, 2010 08:13
Show Gist options
  • Save Raimondi/721332 to your computer and use it in GitHub Desktop.
Save Raimondi/721332 to your computer and use it in GitHub Desktop.
incrementor.vim
" http://vim.pastey.net/142521
" Author: bairui
function! Incrementor(start, step)
let incrementor = {}
let incrementor.initial_value = a:start - 1
let incrementor.value = incrementor.initial_value
let incrementor.step = a:step
function incrementor.inc() dict
let self.value += self.step
return self.value
endfunction
function incrementor.val() dict
return self.value
endfunction
function incrementor.next() dict
call self.inc()
let val = self.value
return val
endfunction
function incrementor.reset() dict
let self.value = self.initial_value
return self.value
endfunction
return incrementor
endfunction
let inci=Incrementor(1,1)
30,30s/\d/\=inci.next()/g
finish
c1 c1 c1 c1 c1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment