sponsor Vim development Vim logo Vim Book Ad

intermediate Tip #142: Automatic function end commenting for C++ and Java

 tip karma   Rating 12/9, Viewed by 2517 

Read and edit this tip on the Vim tip wiki. The wiki may have a more recent version of this tip.

created:   October 19, 2001 9:44      complexity:   intermediate
author:   Kalle Björklid      as of Vim:   6.0

Some people have a habit of adding the function name as a comment to the end of that function, if it is long, so that he/she knows which function the '}' ends. Here's a way to automate the process.

Use the following abbreviation:
iab }// } // END: <esc>10h%$?\w\+\s*(<cr>"xy/\s*(<cr>/{<cr>:nohl<cr>%$"xpa

If you now end the function with '}//', the follwoing string will be automatically generated: '} //END: functionname'

 rate this tip  Life Changing Helpful Unfulfilling 

<< Add your function heading with a keystroke | Use of Vim folds for javadocs >>

Additional Notes

bjorklid at jyu.fi, October 19, 2001 10:05
Whoops. It seems that a tip like this has allready been sent here (see vimscript #125). Sorry about that.
bjorklid at jyu.fi, October 19, 2001 10:07
and of course I meant vimtip #125 (not script). I begin to feel a little foolish here ;-)
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Sponsored by Web Concept Group Inc. SourceForge.net Logo