Vim Tips Wiki

Use recording to easily add function skeletons from prototypes

1,610pages on
this wiki
Revision as of 09:41, April 25, 2008 by JohnBot (Talk | contribs)

Tip 1435 Printable Monobook Previous Next

created December 8, 2006 · complexity intermediate · author Peter Jenkins · version 5.7

:let @u = "<<<<<<<<<<dd?int main(^MkO^[pY/main(^M/{^M%o^M^[p^[kdd$s^M{^M^M^M}^[kki^I"

For ^M, ^I, ^[, you need to do ^v first. ^I may show up as a space. you might have to do ^v <tab>

This will take a function prototype wherever it is in your C code, make it flush left (if it's less than 5 or so tabs in), cut it and paste it one line above main, then copy it again to right under main, remove the semicolon, add paired braces, move in between them, tab over and put you in insert mode.

I'm not using recording here, but that's how i generated the register. You can edit the recorded register as described in VimTip144.


Fix title – nothing to do with recording.

Just realized I could have done ^d$dd"2p instead of that messiness with the left shifts.

The simplest way to remove all indentation on current line (if you mean that) is:


Advertisement | Your ad here

Around Wikia's network

Random Wiki