News for hackers. Stuff that matters.
Re:My Favorite Vim Oneliners for Text Manipulation by king_geedorah on Tuesday August 08, 2023 @10:24AM (#37049414)
Makes sense. I suppose one could also use a debug macro that stringifies the statement to avoid the problems you described. Might be something like:

  #define DEBUG_PRINT(stmt) printf(#stmt“ — %d\n”, __LINE__)
Then your replacement could be something like: s/.*/DEBUG_PRINT(&); &;

Which would print out the statement being executed and the line it is at in the program.

Also you’ll want :%s instead of :s, as the latter will only replace on the line on which the cursor is positioned.

Come to think of it, you’ll probably not want this to happen on lines which are themselves preprocessor directives or those with comments, function signatures, or (exclusively) punctuation like with braces. All this to say, I’m sure it could be done, but it gets into the weeds very quickly.

There are no comments on this comment yet.