On Apr 18, 9:50 pm, "John Beckett" <[email protected]> wrote: > googler wrote: > > This is what I actually used after posting the question. But > > I was wondering if there is a better way. > > Use Tim's approach but modify the replacement using: > > http://vim.wikia.com/wiki/Substitute_with_incrementing_numbers > > John
Thanks for the link. It certainly solves my problem. However, I have one question related to the solution given there. :let i=1 | g/foo/s//\="blah_".i/ | let i=i+1 When I run the above, I see that it replaces 'foo' (the first occuerence in a line) with blah_1, blah_2, etc., as the tip claims to do. But I am not very clear on the three separate steps in the process. On first looking at the above command, my understanding was that first we are assigning 1 to i, then running the substitution command over the entire file and then incrementing i -- which is not correct because then the file will have all 'foo' replaced only by 'blah_1' and i incremented only once at the end. So looks like the middle step (substituation) is not an atomic step and rather an (implicit) iterative step. Can someone explain this behavior of the :g and :s command in slightly greater detail or point to some explanation on the same? -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php
