examples
example 1)
in vim command line, type
:php echo "hello world !";
you will see then message "hello world !".
example 2)
save following script to test.php
<?
vim::setLine(1, "hello?");
?>
and type this command in vim.
:phpfile test.php
first line of current buffer will be changed to "hello?"
example 3)
PHP vim interface is designed to fully support power of php's template engine.
file query.php
---
<?
function query($sql) {
?>
Result of <? echo $sql ?>
====================================================
<?
$old = vim::setOutput(VIM_OUTPUT_INSERT);
$db = mysql_connect(DBTEST_HOST, DBTEST_USER, DBTEST_PASSWORD);
mysql_select_db(DBTEST_NAME, $db);
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result)){
print_r($row);
}
vim::setOutput($old);
}
?>
in .vimrc
--
phpfile query.php
command! -nargs=? SQL php query("");
with macro like this, you can query database within vim using following command. output will be inserted on current buffer.
:SQL select * from mytable