Tip #1436: wrap function calls in a print statement
tip karma |
Rating -3/5, Viewed by 441
|
created: |
|
December 8, 2006 15:40 |
|
complexity: |
|
advanced |
author: |
|
Peter Jenkins |
|
as of Vim: |
|
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^]"
<<use recording to easily add function skeletons from prototypes |
Using VIM with the Dvorak Keyboard Layout >>
Additional Notes
|