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.
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.
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.
By pressing <CTRL>+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.
By pressing <CTRL>+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.
Indentation will be performed automatically (forth and back) using 4 spaces.
Line numbers will be diplayed in front of the code by default.
While searching for a pattern, VIM will jump to the next occurence of the current pattern while you type.
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 "".
You just have to hit <CTRL>+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!)
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:
=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 |
If you liked this blog post or learned something, please consider using flattr to contribute back: .
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 <F12> :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.
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 :)
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 :-)
Link to comment
Great tips.
Here is another one:
Save file and run php CLI on it:
imap <F9> :w!<CR>:!php %<CR>
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.
It sounds good, but the link to the .vimrc file does not work!!!!
ERROR 404
:-(
Sorry, please refer to the newer version (from part 3 of the article), here: http://schlitt.info/misc/.vim.tar.bz2
Link to commentSweet, thanks :-)
Link to commentGreat 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.
Link to comment
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
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
Link to comment
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
If you want the best digital cameras, get those with a resolution of 10 megapixels or better. The lens zoom range should be 28 mm to 140 mm, at least. Supported storage media include SD/HC, CompactFlash, xD-Picture Card and Memory Stick.
Link to commentAnyone dealing with RS232, RS422 or RS485 serial data communication, USB, Ethernet or TTL will occasionally have to convert and/or between them, extend reach, or add isolation.
Link to commentWhether you are trying to get back your beach body before summer or training for a sport, gaining upper body mass is important. There are two critical necessities to gain upper body mass: proper dieting, and regular exercise and lifting. Put simply, to gain weight you must consume more energy than your body expends; however, working out is important because it will make sure the extra intake is put toward building lean muscle rather than fat
Link to commentChoose a mild soap that does not have any additional scents or dyes added; such additives can cause irritation to sensitive areas. Scented feminine products can be used to help mask the odor but may irritate the skin. If irritation occurs, discontinue use. Removing the hair around the feminine area through waxing or shaving can help reduce bacteria and the resulting odor. Remove wet clothes, such as gym clothes, immediately, as this can worsen any odor issues.
Link to commentPets are loved by everyone for many reasons; no matter what breed of animal you own, they can bring happiness to lives
Link to commentFields with bold names are mandatory.
Enhancing firefox... -2-
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-
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)
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-
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