html2textを利用してVimからPHPマニュアルをサクっと開いてみる
ついカッとなってやった。マニュアルが見られればなんでもよかった。
- html2text必須
nmap M :call RefsPhpMan()<CR> function! RefsPhpMan() " let proxy = '--proxy http://proxy.com:8080' let proxy = '' let str = expand("<cword>") let word = substitute(str, '_', '-', 'g') let res = system('path=`curl -I ' . proxy . ' "http://jp.php.net/manual-lookup.php?lang=en&pattern=' . word . '" --silent | grep Location | awk "{print $2}" | sed -e "s/.*\/\([^\/]*\)/\1/g" | sed -e "s/\.php/.html/g"` ; curl --location --silent --use-ascii ' . proxy . ' "http://cs.unomaha.edu/local/php_manual/"$path | html2text -width 100 -style pretty | col -bfx') let res = substitute(res, '>', '>', 'g') let res = substitute(res, '<', '<', 'g') let res = substitute(res, '"', "'", 'g') let res = substitute(res, '&', '&', 'g') let res = substitute(res, '—', '―', 'g') echo res endf
上記のソースを.vimrcか.vim/ftplugin/php.vimに貼り付けて、PHPの関数の文字の上にカーソルを合わせてMを押すと英語のマニュアルがサクっと開きます