It's nearly 4 month ago now, since I last blogged about my .vimrc (the main Vim config file) and the recent enhancements I added to it. This time, I go a step further as in the last 3 parts: I wrote my first own Vim script. :) Beside that there are as usual some other great enhancements and tips I collected over the past 4 month and I already have an idea of how to proceed and what I need more. But first, I'd like to give a brief changelog between version 1.3 and the last version:
Fixed bug with cover char mapping of "" in visual mode.
Mapped ; in command mode to check if the current line ends with a semicolon and to add it, if it's missing.
Configured :make command to run "php -l" and jump to the line of the first compile error afterwards.
Added setting for not highlighting every search result (which is a Gentoo standard setting).
Added laststatus=2 which makes a nicer ruler (thanks Derick!).
Moved PHP specific settings to a file type plugin in .vim/ftplugins/php.vim (only global options are left in the .vimrc itself).
Activated automatic sourcing of ftplugins (so that the php.vim is included for PHP files).
Added file type setting for .phps files to PHP.
Added possible alternatives for other coding standards for mappings of {} and ().
These changes are mostly of cosmetic nature and the real enhancement is the script I wrote. I was searching for a longer time for a really convenient documentation plugin to let Vim generate phpDoc conform doc blocks for my classes/functions/methods/... . Sadly I did not find anything beside the scripts by Karl Heinz Marbaise and Vidyut Luther, which both did not satisfy my needs or even almost work. So I started hacking around in Vidyut's script to fix it and the result was PDV (phpDocumentor for Vim), a complete rewrite. PDV version 1.0.0 supports the following features:
Generation of phpDocumentor conform docs for
Classes
Methods/Functions
Attributes
Supporting for PHP 4 and 5 syntax elements.
Define default values for phpDocumentor tags like @version (I use $id$ here), @author, @license and so on.
For function/method parameters and attributes, the script tries to guess the variable type as good as possible from PHP5 type hints or default values (for array, bool, int, string...).
Generating doc blocks for single lines, all known elements in a visual selection and over a whole file (where in the latter cases existing documentation is taken into account).
I'll provide a copy of this script with my blog series in combination with my .vimrc and the FTPlugin, but maintain the script itself independantly on vim.org. More features will surely come soon (I already planned support for constants and some other constructs, as well as documenting whole directories and some more stuff)!
You can download my actual .vimrc-package (since it's no more only a single file) here (CAUTION: If you already have a .vimrc, don't extract this package directly to your home diretory!).
Last for today, some tipps for using Vim:
All those enhancements (especially auto-indent and close char mapping) make it more or less impossible to paste text from other application to Vim. Thanks to Derick who showed my the settings ":set paste"/":set nopaste", which switch all enhancements off for insert mode.
Jakob Westhoff (from our local user group) told me about the combination <z>+<f> in visual mode, which wraps the selected parts into Vim fold-tags. Sadly this does not create the tags like I want it by now, but I guess I can change that somehow.
Hope you like it, 'till next time!
P.S.: I'll maybe write an extended entry for this one, when I find time, to explain the features in detail.
UPDATE:
Because of so many questions about it: The link to my .vimrc above is outdated. Please refer to my SVN repository for a recent version!
[/quote]
Mapped ; in command mode to check if the current line ends with a semicolon and to add it, if it's missing.
[/quote]
Hej funny. I had the same idea some weeks ago, but i didn't think to include a check. Good idea - i will implement this as well. Nice work.
* due the fact that the moinmoin Wikiformating (http://projects.edgewall.com/trac/wiki/WikiFormatting) didn't work, i just used bb-code.
Cheers jerik
PS: Vim Rules !!
nice work man.
I found a little bug in PDV! when my parent class named with underscore like OSC_Model PDV generate incorrectly result.
please add folding capabaliti for your wonderful PDV, Tanks.
PS: Sorry for my bad english ;-(
Hi, nice idea about the ';' map :]. Here's another mapping to show the result inside Vim window ^_^
map ;; :echo system("php -l ".expand("%"))
thank you for all of this... i will have to study that fore several evenings.
you might just want to add the following lines into the general purpose .vimrc ... that way, you have standard syntax hiLight on, when editing files non specified by the files in the .vim/ftdetect ...
such as the .vimrc itsel ;)
" let vim have colors
let color = "true"
if has("syntax")
if color == "true"
so ${VIMRUNTIME}/syntax/syntax.vim
else
syntax off
set t_Co=0
endif
endif
does this correctly handle syntax-coloring "less-than sign", "greater-than sign", and -> occuring within php blocks?
Link to commentAKA, does it correctly color "ASP-style" tags in PHP?
Link to commentNope, I don't think so. Do not use them! Just use the correct PHP tags!
Link to commentOh. Why do you suggest not using them? They are easier to type, compatible with JSP & ASP, and PHP has supported them just fine since version 3.0.4.
Link to comment
Because you are writing PHP, not ASP or JSP. :) Additionall, if you write an application for more than personal use (distribution, open source, custumers,...) you can never be sure that a server your application is deployed to supports them. So your application becomes a lot less portable.
Beside that, (almost?) all major PHP projects discourage all other tags except the official PHP tags and it is commonly considered good coding manor to use those.
Another side note: ASP tags will be gone in PHP 6. See http://php.net/~derick/meeting-notes.html#id66
Link to commentThe download link for your .vimrc package is broken?
Link to commentPlease download it from SVN: http://svn.toby.phpugdo.de/PDV/. Beware, I splitted the .vimrc to the actual file and the FTPlugin in addition (.vim/ftplugin/).
Link to comment
chem91-77-dhcp:~ ruckerz$ svn checkout http://svn.toby.phpugdo.de/PDV/" title="http://svn.toby.phpugdo.de/PDV/">http://svn.toby.phpugdo.de/PDV/
svn: PROPFIND request failed on '/PDV'
svn: PROPFIND of '/PDV': 301 Moved Permanently (http://svn.toby.phpugdo.de)
chem91-77-dhcp:~ ruckerz$
?
Sorry, that is only for web access. Checkouts can be done like this:
svn co svn://phpugdo.de/PDV
That is because I run Lighttpd and not Apache. ;)
I love your series, but I never manage to get the command mappings to work.
When I try to write f.x.
=roc nothing happens. I believe I've got some simple thing wrong here. Does anyone have a tip on how to debug command mappings?
Also, have you looked at this script for autoindenting php?
http://www.vim.org/scripts/script.php?script_id=1120
Fields with bold names are mandatory.
VIM - still a choice for PHP programmers
Maybe you though that VIM is obsolete, and that power PHP programmers use large, expensive, highly integrated point'n'click IDEs. Think again. Tobias Schlitt has a series of articles about Comfortable PHP editing with VIM which may change your opinion abo
PDV - phpDocumentor for Vim
PDV - phpDocumentor for Vim - Provides generation of phpDocumentor doc blocks for PHP4 & 5. Tobias Schlitt has rewritten my vim phpDoc plugin. I’ve been testing it for a few days now, and it’s a lot better than what I had. It does ...
PDV example
I just realized that I missed to show some examples for my phpDocumentor for Vim plugin. So, here they are:
Before using PDV. After visually selecting the whole file and running PhpDocRange?() (all options switched to on, you can adjust your output segn
They must think I'm cheating...
PDV (phpDocumentor for Vim) ran into the top 10 PHP Vim scripts on vim.org within 2 from it's first publishing... and I did not even vote once... that's a bit scary, isn't it?
documentation
es gibt 3 verschieden Kommentarzeichen in php, die scheinbar unerschöpfliche Kombinationsmöglichkeiten von Funktionsheadern zulassen. Als bugbuster bei myfotofactory komm ich nicht drum rum sie lesen zu müssen.Um so schöner ist jetzt meine heutige Entde
PHP und VIM
Heute bin ich endlich mal dazu gekommen die .vimrc von Tobias Schlitt zu testen. In seinem Blog hat er mehrfach ausführlich darüber berichtet. Schön ist neben der Code-Completition auch die Einbindung von phpDocumentor.
Jedem PHP-Entwickler kann ich
Vim buat PHP koder
Tips and tricks vim buat PHP koder:
Prerequirement: PHP versi 5 cgi/cli
Instal php vimrc punya e tobias di sini.
cara install phpm:
downlod di http://eide.org/view/php
download semua xml nya, edit settings.xml, phpm (set path)
Tambahkan PHP
Comfortable PHP editing with VIM -5-
More than a half year after my last "Comfortable PHP editing with VIM" post, I take up this series again, although I decided to let it die in January. Sadly I did not find any time by now, to extend PDV (the PHP Documentor for VIM plugin) furthe
PHP Documentor for VIM documented
Because I had a talk about how to use VIM in respect to PHP source code editing, I took the time during the week, to write some extensive documentation for PDV, the PHP Documentor plugin for VIM. Additionally, I documented my VIM file type plugin, which i
Latest News
Latest News