Created
November 30, 2010 08:13
-
-
Save Raimondi/721332 to your computer and use it in GitHub Desktop.
incrementor.vim
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" 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