vim code completion fu

Thanks to jMCg, _Lewellyn, and various others on #apache for examples and inspiration, I now have the following in my .vimrc

” Autocomplete stuff for .php, .pl files, thanks to jMCg, _Lewellyn, et
” al on #apache.
au FileType php,pl :abbrev if if () {<CR>}<ESC>klllli
au FileType php,pl :abbrev else else {<CR>}<ESC>O
au FileType php,pl :abbrev elseif elseif {<CR>}<ESC>O
au FileType php :abbrev /** /**<CR> *<CR>*/<ESC>kA
au FileType php :abbrev switch switch ( ) {<CR><CR>case ‘foo’ :<CR>break;<CR><CR>default :<CR>break;<CR>}<ESC>kkkkkkkllllllla
au FileType php :abbrev function /**<CR> * Description<CR>*<CR>* @param<CR>* @return<CR>*/<CR><ESC>A<CR>function() {<CR>}<ESC>klllllllli

It’s nothing terribly fancy, but it expands if, else, elseif, and function to full code blocks, and, in the case of function, gives a skeleton phpdoc block all ready for useful documentation. And it will save me a lot of typing.

Note that each au starts a new line. I imagine the lines wrap rather differently in your browser window.