I've been playing with 500 individual files using VIM to make one of the values unique. I won't paste that as it's a total kludge :)
After making one element Unique I have a single file with 500 records separated by a blank line.
Recorded a macro to mark row 1 then find the blank and mark the previous line then write that block to a file with @b incremented by 1.
Because I couldn't work out how to increment @a during the writing of the file I paste it increment it then yank it back to @a .
"ap0:let @a="""^MAywdd
This all worked fine except every 7 numbers the increment command skips three so instead of XML0001.xml to XML0500.XML I get XML001.xml to XML0763.xml or thereabouts.
Why does the skip 3 numbers every 8th invocation?
I'm just curious as at the moment as long as the files names are unique it doesn't matter what they are numbered but I will eventually need to make the output names match what the value of @b should be.
EDIT Wild guess that it has something to do with the 0 to 9 registers losing track?
Is there a way to increment @a in insert mode something like
:'a,'b w XML"Increment @A".xml
The increment mystery
As your numbers are prefixed with
0
, Vim considers them to be octal, so the increment (with<C-a>
, I suppose) jumps from07
to10
. To fix that, you can remove that (today rather obscure) number format:Directly increment register
If your register contained just the number, you could do:
(Note:
+=
doesn't work, because the register is of string type.)If your register contains the full filename, you have to use
:help sub-replace-expression
to match the first number and increment it:Plugin recommendation
My EditSimilar plugin provides a command that searches for a non-existing offset, and writes (portions of the buffer) to it: