Vim and PHP: tips
Friday, August 31st, 2007
I've been using Vim for years now, but there's still new stuff to learn. Check out this page for the PDF version of the slides of a talk given by Andrei Zmievski on editing PHP with Vim. His configuration files are also available.
Here's my favourite list of tips:
Add the following text to your ~/.vim/ftplugin/php.vim file:
set formatoptions+=tcqlro let php_sql_query=1 let php_htmlInStrings=1 let php_folding = 1
- Turn on automatic text formatting for PHP so that, for instance, Vim automatically inserts a '*' if you press enter inside a /* */ comment.
- Makes Vim highlight SQL queries in strings.
- Makes VIm highlight HTML in strings.
- Allows folding on PHP classes and functions. (With the cursor on the first line of a function, press z-c to hide the function. z-o to show it again. (Close and Open the fold)