VIM中PHP函数自动补全

date:星期五, 二月 27th, 2009 at 8:08 下午 Categories:linux

VIM是一款很强大的编辑器

LINUX中经常用到

有着使用方便,语法高亮等多方面的特色

现在为VIM增加PHP函数的自动补全

首先下载PHP函数列表文件

http://cvs.php.net/viewvc.cgi/phpdoc/funclist.txt

修改VIMRC

增加

“You can obtain the completion dictionary file from:
” http://cvs.php.net/viewvc.cgi/phpdoc/funclist.txt
set dictionary-=/etc/funclist.txt dictionary+=/etc/funclist.txt

“Use the dictionary completion
set complete-=k complete+=k

那么如何解决缩进的问题呢

我们肯定不愿意在映射另外一个键来做缩进用,感觉会很别扭。下面的函数会解决这个问题。

“Auto completion using the TAB key
“This function determines, wether we are on
“the start of the line text(then tab indents)
“or if we want to try auto completion
function! InsertTabWrapper()
let col=col(‘.’)-1
if !col || getline(‘.’)[col-1] !~ ‘\k’
return “\”
else
return “\”
endif
endfunction

“Remap the tab key to select action with InsertTabWrapper
inoremap =InsertTabWrapper()

*记得 修改红色那段,改成你的列表文件的地址

Leave a Reply