Vim Tips Wiki
Register
Advertisement
Tip 1436 Printable Monobook Previous Next

created 2006 · complexity advanced · author Peter Jenkins · version 5.7


warning: i couldn't get this to work except by entering the commands, maybe there is a way to get the let statement to work but for me it has problems with the quotes. I couldn't figure out a way to properly escape them.

have you ever had a function in C: doSomething(a, b, c); and you want to see what it's printing out? this wraps that function so the output looks like this:

doSomething(a,b,c): 37

c for it looks like printf("doSomething(a,b,c): \"%s\"\n", doSomething(a,b,c));

kind of a pain to type often. i also try to make it so the cursor ends up over the s so that you can replace it with d, etc for printing things other than strings. again, this works if you type in the commands as they are depicted, but not with the let statement. if you want to do it by hand, do something like qt (to assign it to "t"). then type what's in between the quotes, starting with 0.

:let @a = "0f(byt;iprintf("^[pa: "~@kb\"%s\"\n", ^[$i)^[?%^Ml^]"

Comments[]

You should use a debugger for this sort of operation.


In fact, you can define

#define hcffl printf("\n= [ %s : %s : %d ] =", \
 __FILE__,__FUNCTION__,__LINE__ \
 ); fflush(stdout);

then, add

hcffl;

every where you need, and

#define hcffl ;

to remove all these printf when make release version.


Advertisement