Permalink
Browse files

Version 2.21

- FIX: In gpp and gPp, keep leading zeros when incrementing the number.
- FIX: In gpp and gPp, do not interpret leading zeros as octal numbers when incrementing.
  • Loading branch information...
1 parent 035ee5d commit 852946c86020479bc9ac9e0e49b1117fee31dc7c Ingo Karkat committed with Apr 23, 2013
Showing with 32 additions and 15 deletions.
  1. +7 −7 README
  2. +13 −2 autoload/UnconditionalPaste.vim
  3. +12 −6 doc/UnconditionalPaste.txt
View
14 README
@@ -54,19 +54,19 @@ USAGE
queried (gup) separator pattern, then paste
linewise.
-["x]gpp, ["x]gpP Paste with the first number found on or after the
- current cursor column (or the overall first number, if
- no such match, or the last number, if the cursor is at
- the end of the line) incremented / decremented by 1.
+["x]gpp, ["x]gpP Paste with the first decimal number found on or after
+ the current cursor column (or the overall first
+ number, if no such match, or the last number, if the
+ cursor is at the end of the line) incremented /
+ decremented by 1.
Do this [count] times, with each paste further
incremented / decremented.
-["x]gPp, ["x]gPP Paste with the all numbers incremented / decremented
- by 1.
+["x]gPp, ["x]gPP Paste with all decimal numbers incremented /
+ decremented by 1.
Do this [count] times, with each paste further
incremented / decremented.
-
CTRL-R CTRL-C {0-9a-z"%#*+/:.-}
Insert the contents of a register characterwise
(newline characters and indent are flattened to
@@ -11,6 +11,10 @@
" http://vim.wikia.com/wiki/Unconditional_linewise_or_characterwise_paste
"
" REVISION DATE REMARKS
+" 2.21.022 11-Apr-2013 FIX: In gpp and gPp, keep leading zeros when
+" incrementing the number.
+" FIX: In gpp and gPp, do not interpret leading
+" zeros as octal numbers when incrementing.
" 2.20.021 18-Mar-2013 ENH: Add gPp / gPP mappings to paste with all
" numbers incremented / decremented.
" 2.20.020 15-Mar-2013 ENH: gpp also handles multi-line pastes. A
@@ -117,6 +121,13 @@ function! s:Unjoin( text, separatorPattern )
" pasting. For consistency, do the same for a single leading separator.
return (l:text =~# '^\n' ? l:text[1:] : l:text)
endfunction
+" Note: Could use ingo#number#DecimalStringIncrement(), but avoid dependency to
+" ingo-library for now.
+function! s:DecimalNumberStringIncrement( number, offset )
+ " Note: Need to use str2nr() to avoid interpreting leading zeros as octal
+ " number.
+ return printf('%0' . strlen(a:number) . 'd', str2nr(a:number) + a:offset)
+endfunction
function! s:IncrementLine( line, vcol, replacement )
if a:vcol == -1 || a:vcol == 0 && col('.') + 1 == col('$')
" Increment the last number.
@@ -132,7 +143,7 @@ function! s:IncrementLine( line, vcol, replacement )
endif
endfunction
function! s:SingleIncrement( text, vcol, offset )
- let l:replacement = '\=submatch(0) + ' . a:offset
+ let l:replacement = '\=s:DecimalNumberStringIncrement(submatch(0),' . a:offset . ')'
let l:didIncrement = 0
let l:vcol = 0
@@ -152,7 +163,7 @@ function! s:SingleIncrement( text, vcol, offset )
return [l:vcol, join(l:result, "\n")]
endfunction
function! s:GlobalIncrement( text, vcol, offset )
- let l:replacement = '\=submatch(0) + ' . a:offset
+ let l:replacement = '\=s:DecimalNumberStringIncrement(submatch(0),' . a:offset . ')'
return [0, substitute(a:text, '\d\+', l:replacement, 'g')]
endfunction
View
@@ -75,15 +75,16 @@ USAGE *UnconditionalPaste-usage*
linewise.
*gpp* *gpP*
-["x]gpp, ["x]gpP Paste with the first number found on or after the
- current cursor column (or the overall first number, if
- no such match, or the last number, if the cursor is at
- the end of the line) incremented / decremented by 1.
+["x]gpp, ["x]gpP Paste with the first decimal number found on or after
+ the current cursor column (or the overall first
+ number, if no such match, or the last number, if the
+ cursor is at the end of the line) incremented /
+ decremented by 1.
Do this [count] times, with each paste further
incremented / decremented.
*gPp* *gPP*
-["x]gPp, ["x]gPP Paste with the all numbers incremented / decremented
- by 1.
+["x]gPp, ["x]gPP Paste with all decimal numbers incremented /
+ decremented by 1.
Do this [count] times, with each paste further
incremented / decremented.
@@ -194,6 +195,11 @@ IDEAS *UnconditionalPaste-ideas*
==============================================================================
HISTORY *UnconditionalPaste-history*
+2.21 23-Apr-2013
+- FIX: In gpp and gPp, keep leading zeros when incrementing the number.
+- FIX: In gpp and gPp, do not interpret leading zeros as octal numbers when
+ incrementing.
+
2.20 18-Mar-2013
- ENH: gpp also handles multi-line pastes. A number (after the corresponding
column) is incremented in every line. If there are no increments this way,

0 comments on commit 852946c

Please sign in to comment.