Wednesday, May 15, 2013

vim macro: c declaration to c definition outline

There is probably a prettier way to do this, but I've made my "d register the following macro

yy0Gi^Mp<80>kb^[pA<80>kb {^M^M}^M^M^[^O<80>kd

this will copy a c declaration, move it to the bottom of the file, replace the ; with an opening curling brace and insert a closing curly brace a few spaces down, before going back to the initial declaration and moving down.  This lets you use a range

so 10@d will do this with 10 declarations as long as they don't have spaces.

pretty useful for me.