sponsor Vim development Vim logo Vim Book Ad

php_abb : abbreviations for php functions

 script karma  Rating 17/9, Downloaded by 2609  Comments, bugs, improvements  Vim wiki

created by
culley harrelson
 
script type
ftplugin
 
description
php_abb is a ftplugin for php, mostly providing insert mode abbreviations
for php builtin functions and control structures.  These abbreviations
expand to function stubs and should help you remember the syntax in
addition to speeding typing.  A map-like function that does a number of
possibly obtuse things is also included.

The insert mode abbreviations come in two falvors: those using the raw
php function name (these can be disabled) and those prefixed with g:phpLeader.  
See the help file for details.

The phpActOnVariable function performs a number of activities on the php
variable under your cursor at the time the function is executed.  You should
create a map to this function.  As an example of how you would use this, say you
have mapped it to <leader>m and you have your cursor on any letter in the word
test in the following code:

     $test = "FooBaR";

If you then type <leader>m and strtl<cr> a new line will be opened underneath
and the following code will be inserted:

     $test = strtolower($test);

You can see a list of all the mappings for this function by executing the
function and entering '?' when prompted.
 
install details
Untar in your ~/.vim directory (or equivalent).  Inside Vim, enter this:
   :helptags ~/.vim/doc
(or equivalent directory)

Then enter
  :help php_abb
for information

You should create a few maps similar to:

imap <F7>  <esc>:call ReplacePlaceHolder()<cr>a
nmap <F7>  :call ReplacePlaceHolder()<cr>
nmap <leader>m <esc>:call PhpActOnVariable()<cr>

in the main script or in another php ftplugin file.  Something like:

~/.vim/ftplugin/php_settings.vim
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
php_abb.tar 1.1 2003-05-28 6.0 culley harrelson Added 3 new settings: g:phpNewlineBeforeBrace, g:phpFoldMarkerFunctions, g:phpRequireIncludeParens.  I also added support for the following php functions: is_null, is_numeric, empty
php_abb.tar 1.0 2003-05-25 6.0 culley harrelson Complete rewrite.  The theme of this rewrite was: quit polluting the mapping namespace, allow for most everything to be customized, remove all personal stuff from the script and write documentation.  All maps have been wrapped into a function and all abbreviations are now prefixed with g:phpLeader so you can change this variable and change the prefix for every abbreviation.  Abbreviations are now created in a more modular fashion so it should be much easier to maintain the script.  I have bumped the version to 1.0-- the structure should *finally* be mostly set so I can now focus on extending the script to cover additional php functions.
php.tar .4 2003-05-03 6.0 culley harrelson ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
script version .4
Uloaded to vim.org 2003-05-03
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

--------------------------------------------------------------
php functions added
--------------------------------------------------------------
bool array_key_exists ( mixed key, array search)
int count ( mixed var)
string htmlspecialchars ( string string [, int quote_style [, string charset]])
string strstr ( string haystack, string needle)
int strcasecmp ( string str1, string str2)
string substr ( string string, int start [, int length])
void trigger_error ( string error_msg [, int error_type])

--------------------------------------------------------------
new PEAR DB stuff
--------------------------------------------------------------
phpgr -- $data = $dbh->getRow($sql);<cursor>
phpgcol -- $dbh->getCol($sql);<cursor>
phpni -- $<cursor> = $dbh->nextId('php~x', false);

--------------------------------------------------------------
misc new stuff
--------------------------------------------------------------
phptodo -- //TODO:
php.tar .3 2002-11-16 6.0 culley harrelson Complete rewrite.  The new format should allow me to continue through the built in php functions till I die.  See the script header for details.

New items:

echo
explode
require_once()
strlen
strcmp
str_replace
strtolower
strtoupper
unset
wordwrap

There are about 6 or 7 other new things that I can't remember...

php.vim .2 2002-10-31 6.0 culley harrelson new abbreviations:

phplv     - look up the last value from a postgresql sequence
phpserver - output $_SERVER['<cursor']
phpgassoc - output $data = $dbh->getAssoc($sql);
phpwhile  - output while structure

new maps:

<leader>ap  - when on an array variable open a line under cursor and output an array_push function
<leader>ae  - when on an array variable open a line under cursor and output the extract function
<leader>apr - when on an array variable open a line under cursor and output the print_r function


php.vim .1 2002-10-21 6.0 culley harrelson Initial upload
ip used for rating: 3.22.61.246

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github