1. 程式人生 > >實現vim編輯器自動補全php程式碼

實現vim編輯器自動補全php程式碼

有時候需要在伺服器端修改程式碼,但是沒有自動補全功能實在是麻煩,就學習了一下,實現了自動補全功能

一:下載php函式庫

二:複製到家目錄中一個目錄中

例如:我複製到了 /root/.vim/目錄中
這裡寫圖片描述

三:在~/.vimrc中新增如下程式碼

autocmd FileType php set omnifunc=phpcomplete#CompletePHP
set dictionary+=/root/.vim/php_functionlist.txt
set complete-=k complete+=k
function! InsertTabWrapper()
let col=col(‘.’)-1
if !col || getline(‘.’)[col-1] !~ ‘\k’
return “\”
else
return “\”
endif
endfunction
inoremap =InsertTabWrapper()

四:注意

autocmd FileType php set omnifunc=phpcomplete#CompletePHP
set dictionary+=/root/.vim/php_functionlist.txt //這是php函式庫路徑,不要寫錯了,可以自己修改
set complete-=k complete+=k
function! InsertTabWrapper()
let col=col(‘.’)-1
if !col || getline(‘.’)[col-1] !~ ‘\k’
return “\”
else
return “\”
endif
endfunction
inoremap =InsertTabWrapper()