Unix iTOps Tube

Monday, April 30, 2012

Weird behavior of Vi

Hi there,



I am a bit puzzled by a weird behavior of Vi. I very simply would like to add increased numbers in some files. Since I have many thousands entries per file and many files, I would like to macro it in vi.



To do this, I enter the first number ("0001") on the first line and then yank it, insert it at the right place one line below, increment it and return to starting position on the line.


Code:


qa

4y<right arrow>

<down arrow>

<left arrow>

p

[Ctrl + a]

4<left arrow>


And it works :) ... by batches of either 7 lines, 70 lines or 700 lines :( . Because after each number "7", the auto-increase jumps to the next X0, X00 or X000!? :confused:

Examples :

... 0006 0007 0010 0011 ...

... 0036 0037 0040 0041 ...

... 0076 0077 0100 0101 ...

... 0156 0157 0160 0161 ...

... 0776 0777 1000 1001 ..., etc



It doesn't make any sense and I really very much don't understand.... Does anybody know what's going on ? :wall:



cheers!

J



[edit: typo]




No comments:

Post a Comment