The following is roughly what I am trying to do in vim
:let g:ID = 1 :%s/^/\= g:ID | let g:ID = g:ID * 1.2/
Now, it looks like vim disregrads everything after the bar
(that is the
let g:ID = g:ID * 1.2 part.
I could of course write a function that multiplies g:ID with 1.2 and returns g:ID's value, but I'd like to forego this.
edit for clarity:
In vim-script, I can write multiple statements on one line if I use the bar (|) to chain them. So, instead of
let g:ID = 20 let g:ID = g:ID * 1.2 let g:ID = g:ID * 1.2
I could also write
let g:ID = 20 | let g:ID = g:ID * 1.2 | let g:ID = g:ID * 1.2
Now, the \= thingy allows me to substitute a regular expression with a vim script expression. For example, I could do a
which would replace every occurence of ABC in my current buffer with the line number on which it is found.
would write the current value of g:ID at the beginning of each line in my buffer.
That's all fine and dandy, but I'd like to have more than one expression in the replacement part and was wondering if I could achieve that by chaining such expressions with the bar. In my case, I'd like to manipulate g:ID after every substitution call, hence
:let g:ID=20 :s/^/\=g:ID|let g:ID=g:ID * 1.2/
would result in writing 20 at the beginning of the first line in my buffer, 24 at the beginning of the second line in my buffer, 28.8 at the beginning of the third line in my buffer and so on.
I hope I made myself clearer now.