Friday, March 27, 2009

Vim: line number trick

I have 89 line of code and would like to add the line number in it. E.g., change
hashImages.insert("CPE_GRAY_POWERLINE_NORMAL",

into:
hashImages.insert("CPE_GRAY_POWERLINE_NORMAL", mImageList[0]);
till:
hashImages.insert("SUBSTATION_YELLOW_ANY_COLLAPSED", mImageList[88]);

A vim trick to do this is:
g/^/exe ":s/$/mImageList[".line(".")."]);"


I got the idea from here.