I have a long script file that I need to run in an application. I generally create these by running a query against the application and then creating the script I need using VIM. Sometimes these can become very long (millions of lines long), but the product handles it just fine. It just takes time.
I run these in the product API through a terminal session. The problem with this is that I never know how far along it is in processing the script. I would like to add line numbers after a comment character. I can then compare what I see in the running script against the total number of lines and guess when it will complete.
The comment character is a # after which I can add whatever text I want. The script engine will ignore what follows a # character. I can easily select lines to place this on because the script I'm running has some blank lines between every set of about 15 commands. So roughly 15 actual lines of commands and then 2 blank lines and then 15 more lines and so on.
Here's the problem though. It seems that using a command like
g/^$/s//\#\=printf('%d',line('.'))/
generates an error. It doesn't matter what text I add, i get an error if the text I want to insert includes anything other than \=printf('%d',line('.'))
. As a result, I can't prefix this with the comment character #.
Is there some other syntax I can use to do this?
\=
must be at the start of the substitution pattern; so putting a\#
in front of that isn't valid. I think perhaps\=printf('# %d',line('.'))
might do what you want? It might be helpful if you could post a simple "before" and "after" example, because I'm not sure if I parsed your requirements from the text exactly 😅