Tip #1435: use recording to easily add function skeletons from prototypes
tip karma |
Rating -1/3, Viewed by 421
|
created: |
|
December 8, 2006 14:36 |
|
complexity: |
|
intermediate |
author: |
|
Peter Jenkins |
|
as of Vim: |
|
5.7 |
Figuring this out showed me what vim is capable of.
:let @u = "<<<<<<<<<<dd?int main(^MkO^[pY/main(^M/{^M%o^M^[p^[kdd$s^M{^M^M^M}^[kki^I"
note, 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.
it could be made nicer, but it gets the job done.
i guess i'm not using recording here, but that's how i generated the register. you can edit the recorded register as described here: vimtip#144
<<as you type (or paste) in Makefile, autoconvert leading eight spaces to tab |
wrap function calls in a print statement >>
Additional Notes
|