Wikia

Vim Tips Wiki

Changes: Automatically generate PHPdoc comments

Edit

Back to page

(Standard category names + minor manual clean.)
(Change <tt> to <code>, perhaps also minor tweak.)
 
Line 28: Line 28:
 
</pre>
 
</pre>
   
Put the cursor on the first line and type <tt>:call JCommentWriter()<CR></tt>
+
Put the cursor on the first line and type <code>:call JCommentWriter()<CR></code>
   
 
You get:
 
You get:
Line 54: Line 54:
 
</pre>
 
</pre>
   
Put the cursor on the first line and type <tt>:call JCommentWriter()<CR></tt>
+
Put the cursor on the first line and type <code>:call JCommentWriter()<CR></code>
   
 
You get:
 
You get:
Line 81: Line 81:
   
 
===Note===
 
===Note===
It does not work if you have <tt>= ''</tt> like in
+
It does not work if you have <code>= ''</code> like in
 
function serialize_it($something = '') {}
 
function serialize_it($something = '') {}
   

Latest revision as of 05:29, July 13, 2012

Tip 407 Printable Monobook Previous Next

created 2003 · complexity intermediate · author Klaus Horsten · version 6.0


Use JCommenter.vim for php-scripts:

jcommenter.vim : A script for automatically generating JavaDoc comments

PHPdoc is an imitation of JAVAdoc. The syntax between the two languages is very close, see the examples below:

Example 1Edit

A PHP function.

function serialize_it($something) {
  $person = serialize($something);
  return $person;
}

Put the cursor on the first line and type :call JCommentWriter()<CR>

You get:

/**
 *
 *
 * @param $something
 * @return
 */
function serialize_it($something) {
  $personen = serialize($something);
  return $personen;
}

Example 2Edit

A PHP class.

class submenu {
 ...
}

Put the cursor on the first line and type :call JCommentWriter()<CR>

You get:

/**
 *
 *
 * @author
 * @version
 */
class submenu {
 ...
}

Example 3Edit

For a class-variable you get:

/**
 *
 */
var $urls;

NoteEdit

It does not work if you have = like in

function serialize_it($something = ) {}

But I think jscript.vim can be adapted for the use with PHP.

CommentsEdit

Around Wikia's network

Random Wiki