06.22
vim 是一个万能的编辑器 首先需要为 Vim 提供一个 PHP 的函数列表文件,这样 Vim 才能知道如何自动完成一个 PHP 函数。函数列表不需要自己做,PHP 网站上有现成的,拿来用就可以了:
http://cvs.php.net/viewvc.cgi/phpdoc/funclist.txt
得到这个文件,接下来,我们得让vim去找呀,这个找也得需要告诉vim这个文件放在什么地方,我把它放在了
~/.vim目录下,~ 这个就是你自己的用户目录,比如 /home/test 。现在我们在.vimrc(~/.vimrc )中
这么写:
set dictionary-=~/.vim/funclist.txt dictionary+=~/.vim/funclist.txt
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
这个函数的作用是判断当前光标前的一个字符是否为一个 Keyword 字符(:help iskeyword),vim 中用 \k 表示,这个字符的范围大约是所有非空白的可打印的字符,但除开某些特殊字符,比如 @ * ” 等等。
于是效果就出来了,当前导字符为空白或者 @ * 等字符时,Tab 就映射为 成为缩进键。否则就映射为 ,也就是 CTRL+N 调用自动完成功能。
Buy:Zetia.Ventolin.Acomplia.SleepWell.Female Cialis.Wellbutrin SR.Lipitor.Nymphomax.Seroquel.Lasix.Buspar.Female Pink Viagra.Cozaar.Aricept.Amoxicillin.Zocor.Advair.Prozac.Lipothin.Benicar….
Buy:Tramadol.Propecia.Viagra Super Active+.Cialis Super Active+.Viagra Soft Tabs.Cialis.Cialis Professional.VPXL.Levitra.Super Active ED Pack.Viagra Professional.Cialis Soft Tabs.Maxaman.Soma.Zithromax.Viagra Super Force.Viagra….