sponsor Vim development Vim logo Vim Book Ad

newheader.vim : Create function header comment according to a template

 script karma  Rating 7/6, Downloaded by 1098  Comments, bugs, improvements  Vim wiki

created by
erik janssen
 
script type
utility
 
description
Just Another headerformatting script for C/C++. This one does not create headers conform some documenting standard but allows you to specify a template. The template may contain some keywords which are expanded. Start by pressing F7 while the cursor is on or a little above the function in question. If the script finds existing comments just above the function it will neatly format it into the template if the right keyword is found. Example (looking horrible in proportional fonts):

" Example _c_header template file:
" ==============================

" /****************************************************************************
"  *
"  * NAME:        name                                    (date)
"  *
"  * DESCRIPTION: text
"  *
"  * ARGUMENTS:   args
"  *
"  * RETURNS:     -
"  *
"  * PRE:         -
"  *
"  * POST:        -
"  ***************************************************************************/
"

" Suppose you have this function:
" ===============================

" /*
"  * This is just a comment that is long enough to show the features of
"  * newheader.vim. It will do some indenting for you and list your function
"  * arguments
"  */
"
" static void show_header( int width, int length,
"                          byte font, Language *language_selection,
"                      byte color )
" {
"      ....
" }


" Result
" ======

" Place the cursor one or more lines before the function and press F7. It
" gives you:
"
" /****************************************************************************
"  *
"  * NAME:        show_header                                    (2000 okt 27)
"  *
"  * DESCRIPTION: This is just a comment that is long enough to show the
"  *              features of newheader.vim. It will do some indenting for you
"  *              and list your function arguments
"  *
"  * ARGUMENTS:   width:
"  *              length:
"  *              font:
"  *              *language_selection:
"  *              color:
"  *
"  * RETURNS:     -
"  *
"  * PRE:         -
"  *
"  * POST:        -
"  ****************************************************************************/
"
" static void show_header( int width, int length,
"                          byte font, Language *language_selection,
"                      byte color )
" {
"      ....
" }

disclaimer:
I'm using it a few years now, and it is a big timesaver. However, every new project requires me to do another generalisation on the script. If you think it may be usefull for you but produces odd results, drop me line.
 
install details
Copy to your plugin dir. Creating a header is currently mapped to F7. A menu is created in the GUI, which may be deleted if you don't like that
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
newheader.vim 1.0 2004-03-17 6.0 erik janssen Initial upload
ip used for rating: 216.73.216.221

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.
   
Vim at Github