Re: Search and replace as per format
- Srinivas Rao. M wrote:
> Hi Tim, Charles,[...]
> I am rather looking at a generic substitution where the number of open
> quotes are matched, and then add an argument to log(). IN a generic
> aproach we may have a variable number of arguments, just like thwe way
> printf() supports.
> The strings like "module name", LOG_LEVEL_DEBUG, and "The Value of
> status=" can be anything.
> All these needs to be substituted in the .c files.
> On Tue, 2006-09-05 at 12:54 -0400, Charles E Campbell Jr wrote:
>> Srinivas Rao. M wrote:
>>> Hi Vimmers,
>>> I am tasked to replace the pattern
>>> log("module_name", LOG_LEVEL_DEBUG, "The Value of status=%d message",
>>> log("module_name", LOG_LEVEL_DEBUG, "%s:The Value of status=%d
>>> message",__FUNCTION__, status);
Well, please describe exactly what you want to do, and in particular,
how to determine which string(s) to modify (like "The Value of..." and
which not to (like "module name").
I suspect the problem can be solved with an ":args" command (such as
":args **/*.[ch]") followed by ":argdo
g/\<log(/s/something/something/g". Possibly wrapping it in a function if
things like __FUNCTION__ must be specified on each invocation.