schlitt.info - php, photography and private stuff ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Author: Tobias Schlitt :Date: Thu, 27 Nov 2008 18:00:29 +0100 :Revision: 2 :Copyright: CC by-nc-sa ==================================== Comfortable PHP editing with VIM -2- ==================================== :Description: I updated my .vimrc regarding the comments posted for my first entry about "Comfortable PHP editing with VIM". You can see and download it here. I updated my .vimrc regarding the comments posted for my first entry about "`Comfortable PHP editing with VIM`__". You can see and download it `here`__. .. __: /opensource/blog/0278_comfortable_php_editing_with_vim.html .. __: /misc/.vimrc What I changed (in short): - Added remappings for automatic completion of brackets and quotation marks. - Added Rasmus' dictionary completion of PHP functions. - Updated code templates regarding these changes. - Switched to the more readable <...> syntax for special characters. To use the dictionary completion you have to grab Rasmus' function list from `here`__. .. __: http://lerdorf.com/funclist.txt I also had a look at Cream which has been recommended in a comment, but pure VIM seems to be enough for me. :) See the extended entry of a detailed description, what the provided `.vimrc`__ gives you. .. __: /misc/.vimrc ------------------- PHP Syntax checking ------------------- By pressing +B in command mode, the current file will be given to the PHP CLI to perform a syntax check. Since I have PHP4 and PHP5 installed in paralell I call "php4" for checking. This has to be changed depending on your system. ------------ PEAR package ------------ By pressing +P in command mode, the current file will be called with the "pear package" command, which will build a package as defined in the file. Though, the file currently edited should be a package.xml. ------------------------------ Standard compliant indentation ------------------------------ Indentation will be performed automatically (forth and back) using 4 spaces. ------------ Line numbers ------------ Line numbers will be diplayed in front of the code by default. ------------------ Incremental search ------------------ While searching for a pattern, VIM will jump to the next occurence of the current pattern while you type. ---------------------------------- Automatic completion of delimiters ---------------------------------- Delimiters like brackets and quotes will be automatically completed. The cursor will afterwards reside between the delimiters. E.g.: You type " and will end up between "". --------------------------------- Auto completion for PHP functions --------------------------------- You just have to hit +K when you typed the beginning of a PHP function to get it completed automatically or get a list of possible completions. (Attention the function list provided by Rasmus is needed! You also have to customize the location of it to fulfill the needs of your environment!) -------------- Code templates -------------- Automatically generated code templates are available in editor mode through specific strings. For example one can type =pfu and get a skeleton for a private method, including documentation using phpdoc tags. The available code templates are: .. csv-table:: "=req", "require" "=roq", "require_once" "=inc", "include" "=ioc", "include_once" "=def", "define" "=cla", "class" "=puf", "public function" "=prf", "private function" "=pua", "public $" "=pra", "private $" "=for", "for" "=foe", "foreach" "=whi", "while" "=swi", "switch" "=if", "if" .. Local Variables: mode: rst fill-column: 79 End: vim: et syn=rst tw=79 Trackbacks ========== - Enhancing firefox... -2- on Wed, 01 Dec 2004 22:20:31 +0100 in Tobias Schlitt - Weblog Seems like I currently have an affection for continuations. After the sequel to my entry "Comfortable PHP editing with VIM" now a sequel for a much older entry follows. I recently stumbled across this website, where a guy called "skyline&q - Comfortable PHP editing with VIM -3- on Sat, 21 May 2005 02:17:53 +0200 in Tobias Schlitt - Weblog It's time to continue my series, since I again updated my .vimrc in the past weeks for much more comfortable editing of PHP sources using VIM. There are several new features I added: Auto completion of functions using <TAB> Auto reloading - Comfortable PHP editing with VIM (from Tobias Schlitt) on Tue, 26 Jul 2005 23:47:52 +0200 in markus' blog Tobias Schlitt has put together some really useful information how to enhance vim to you can get more productive with vim. Don't miss his articles: Comfortable PHP editing with VIM Comfortable PHP editing with VIM -2- Comfortable PHP editing wi... - Comfortable PHP editing with VIM -5- on Wed, 23 Aug 2006 16:39:01 +0200 in Tobias Schlitt - a passion for php 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 on Fri, 01 Dec 2006 11:49:43 +0100 in Tobias Schlitt - a passion for php 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 Comments ======== - Dennis at Wed, 24 Nov 2004 12:02:16 +0100 Another great feature in vim, is the ability to work with several files at the same time. Add this to .vimrc: " Allow editing of several files without having to save the current one, before moving to another set hidden " map F12 to close a buffer map :db^M " Move to next buffer map ^N :bn^M " Move to previous buffer map ^B :bp^M " List open buffers map ^L :ls^M Then use the 'e' command like: e: text.php This will open text.php in a seperat buffer, and with CTRL-n or CTRL-p you can navigate between them. - Yann Larrivee at Thu, 25 Nov 2004 14:31:39 +0100 Hello i also wrote a introduction to vim. More like a small cheat sheet. That incluse some tricks and covers other extension like DBext let you build queries (say you forgot the table name, field name ...) It has auto completation. It also covers the CVS extension. It is always usefull to have these tools included in VIM. http://www.phpquebec.com/modules/mydownloads/visit.php?cid=2&lid=35 I hope this helps. Sorry the document is in french but i guess some of you can understand the concept :) - Jonathan Oxer at Wed, 09 Feb 2005 01:09:32 +0100 Just a minor point: the main text uses "=pfu" as an example of inserting a private function, while it's actually "=puf". Had me stumped for a while because I naturally used the example in the text while trying to test it! Once I realised the mistake it worked fine :-) - aurelian at Wed, 09 Mar 2005 15:41:34 +0100 Great tips. Here is another one: Save file and run php CLI on it: imap :w!:!php % - Martin Vium at Thu, 14 Jul 2005 22:09:56 +0200 The buffering is nice, but i think my vim is crashing every time i request a non-existent buffer with ctrl+n/p. Isnt it possible to check for that before it calls the "next" "previous". And the filename in the top of the prompt would help aswell. Very neat config Tobias, keep up the good work. - Tim Kersten at Tue, 16 May 2006 11:55:54 +0200 It sounds good, but the link to the .vimrc file does not work!!!! ERROR 404 :-( - Toby at Tue, 16 May 2006 13:06:33 +0200 Sorry, please refer to the newer version (from part 3 of the article), here: http://schlitt.info/misc/.vim.tar.bz2 - Tim Kersten at Wed, 17 May 2006 15:10:18 +0200 Sweet, thanks :-) - Pat at Thu, 12 Jul 2007 11:39:25 +0200 Great article and tips - but all the links to the .vimrc file are broken, even the one given in reply to the previous commenter who reported the same problem. - Toby at Sat, 14 Jul 2007 09:41:13 +0200 Hi! As you can see in the latest posts of my series, the files are all available through my SVN: http://svn.toby.phpugdo.de/PDV Cheers! Toby - programming help at Thu, 01 Apr 2010 11:54:34 +0200 Just a minor point: the main text uses "=pfu" as an example of inserting a private function, while it's actually "=puf". A little slip of the pen - nothing terrible - downloadable files at Fri, 21 May 2010 10:46:56 +0200 Just a comment that the example usage displayed in php-doc.vim should contain ":call PhpDoc()" instead of ":exe PhpDoc()" It will try to execute the returned string when using :exe