View Single Post
Old 09-03-2008, 04:15 PM   #1 (permalink)
sketchMedia
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default phpDoc comment generator for vim

Just thought I'd share this for those hardcore Linux vimmers out there, just a little find that has helped me loads.

It generates phpDoc comment documentation for your PHP classses, functions, methods and attributes.

Download Link

Instructions:


Download the script and put it in a place that vim will be able to access it.

next find your .vimrc file, use this if your are unsure:
Code:
example@talkphp$ locate .vimrc
Then add these code lines to it:
Code:
source /path/to/php-doc.vim
imap <C-o> <ESC>:set paste<CR>:exe PhpDoc()<CR>:set nopaste<CR>
Save it and exit the file. In vim speak that's <Esc> :x <CR> or Escape <shift>+; (to make a colon) then press x followed by enter (Carrage Return)

Next whack open a PHP file in vim:
Code:
sketch@talkphp$ vi phpfile.php
Next find the start of the class etc, then (whilst in insert mode) just press <ctrl>+o (lower case O not zero) and bam! there should be a generated phpDoc comment!
You will need to edit it slightly though, for example add variable types and descriptions (vim cant read your mind, yet)

NOTE
: You must be in insert mode inorder for the keymap to work (as its an imap), to change this to function in normal mode, change the imap line in the .vimrc file to:
Code:
map <C-o> :set paste<CR>:exe PhpDoc()<CR>:set nopaste<CR>
Just make sure your out of insert mode etc buy hitting the Escape key a few times (generally a good tip anyway)

NOTE: I did NOT write this script, full credits go to the author: Tobias Schlitt.
More information can be found in the code comments in the 'php-doc.vim' file.

NOTE: sketch@talkphp$ is my attempt at emulating the linux terminal.

Enjoy.
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)

Last edited by sketchMedia : 12-23-2008 at 06:03 PM. Reason: Download link now works
sketchMedia is offline  
Reply With Quote