Comfortable PHP editing with VIM -2- - Blog - Open Source - schlitt.info

schlitt.info - php, photography and private stuff

Comfortable PHP editing with VIM -2-

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.

PHP Syntax checking

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.

PEAR package

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.

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 <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!)

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:

=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: .

Trackbacks

Comments

Add new comment

Fields with bold names are mandatory.