php maps and abbreviations : functions, control structures, some language constructs, and PEAR code snippets
script karma |
Rating 6/3,
Downloaded by 309 |
created by |
culley harrelson |
|
script type |
ftplugin |
|
description |
The bulk of this file consists of maps and insert mode abbreviations that
output php function and control structure stubs. Each item begins with a
heading similar to
PHP: function definition
Function definitions where copied from the php manual. To see a complete
list if items grep on PHP:
grep "\" PHP: " php.vim
A good overview can also be seen by setting the foldmethod=marker.
Each item should have an insert mode abbreviations prefixed by php. The
print() function, for instance, has this abbreviation: phpprint. In
addition to the full name of the function prefixed with php, I have usually
also attempted to create an reasonable shortened version. For print() this
shortened version is phpp. When it makes sense, abbreviations with the php
prefix have additional output, such as a preceeding variable to make an
expression and a semicolon to end the statement.
When it makes sense, items will also have a normal and visual mode map. For
the print() function there are maps that will open up a new line and insert
a print statement inclosing the variable name under the cursor when the map
was executed. Generally, the map should correspond to the shortened
abbreviation prefixed by <leader>. The definition of each map should be
broken up with <esc>a to avoid the double expansion of the item when
non-prefix abbreviations are being used.
Finally, for each item there should be a disabled abbreviation without any
prefix. When enabled these abbreviations (expanded by the space bar)
complete the function syntax. Typing print would output print(""); and
leave the cursor between the quotation marks. Not everyone is going to want
these abbreviations so they are disabled. To enable them execute this
substitution command:
:%s/\("no-prefix: \)\(.*\)/\2 \1/gc
To put the abbreviations back after they have been removed execute:
:%s/\(.*\) \("no-prefix:\)/\2 \1/gc
These abbreviations have also been gathered together in a separate file to
be sourced at will if you don't want them permanently on. The abbreviation
without prefixes can really make things interesting if you can get used to
it...
Many of the function stubs require data entry in more than one location.
For instance the implode function requires two parameters. The <c-x>, <F7>
and <leader>x maps are an attempt to help with this situation. A
placeholder (php~x) is inserted in positions 2..n of the function that
require data entry. The <c-x>, <F7> and <leader>x maps can then be used to
advance to and replace these placeholders. If this is too ugly for you or
you just don't like the technique you can delete all the placeholders with:
:%s/php\~x//g
The maps and abbreviations have been grouped into these sections:
- php functions
- php language constructs
- php predefined variables
- misc php stuff
- PEAR code snippets
- miscellaneous maps
search for "Section:" to jump around.
set fdm=marker for the folded version |
|
install details |
|
|
script versions (upload new version)
Click on the package to download.
php.tar |
.3 |
16-Nov-2002 |
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 |
31-Oct-2002 |
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 |
21-Oct-2002 |
6.0 |
culley harrelson |
Initial upload |
|