A lot of people use vim as their daily editor. We probably have the experience that it's difficult to remember many functions' parameters, even their usage. Here I want to show how to integrate the PHP manual into vim. This will obviously save you lots of time to look up the manual online, because we just need a SHIFT+k here to get what we need.
Ok, let's begin.
First, download the PHP manual for vim here:
http://phparch.cn/archive/php_manual.txt.zip
Unzip the manual to the directory you prefer. Here we take "~/.vim" for the example.
Then, create a shell script to extract the help part we need, and put it under "~/.vim", too.
Assume the script name is "php_man". Open the script and add the following line into it.
#!/bin/sh
echo -n "\n\033[34m"
sed -n "/ $1(/, /\*/ p" ~/php_manual.txt | grep -v '*'
echo -n "\033[0m"
Save it and change its mode to be an executive shell script.
$ chmod +x php_man
In the ".vimrc" file (usually it's under your home directory), we just need to add the following line:
autocmd FileType php set keywordprg=~/.vim/php_man
Done.
To use the PHP manual help, navigate the cursor onto the function name, press SHIFT+k. and it will take you to the help part:
int file_put_contents(string filename, mixed data [, int flags [, resource context]])
Identical to calling |fopen|, |fwrite|, and |fclose| successively. The
function returns the amount of bytes that were written to the file.
Press ENTER or type command to continue
The known problem that you may meet is that, if you copied the php_man script's content and pasted it into the script, you should do something with "\033":
You'd better manually enter "\n\033[34m" and "\033[0m". Or you can replace "\033" with "^[" (press CTRL+v, then ESC). If "\n" makes you feel uneasy, you can get rid of it.
Here we use "\033[34m" to change the help text color. For more explanation about the color details, have a look at this topic (Language is in Chinese, but you can understand it regardless of the language):
http://phparch.cn/index.php/linux/44-linux-application/224-colorful-shell