私は現在、PHPファイルのvimでPHP Codesniffer (PEAR)を使用しようとしています。$HOME/.vim/plugin/phpcs.vim
ファイルに追加するコードを提供する 2 つのサイトを見つけました。コードを追加しましたが、機能していると「思います」が、結果が表示されません.vimの一番下に1行しか表示され(1 of 32)
ませんが、32個のエラーは表示されません。
ここに私の .vimrc ファイルがあります
" Backup Options -> Some People may not want this... it generates extra files
set backup " Enable Backups
set backupext=.bak " Add .bak extention to modified files
set patchmode=.orig " Copy original file to with .orig extention Before saving.
" Set Tabs and spacing for PHP as recomended by PEAR and Zend
set expandtab
set shiftwidth=4
set softtabstop=4
set tabstop=4
" Set Auto-indent options
set cindent
set smartindent
set autoindent
" Show lines that exceed 80 characters
match ErrorMsg '\%80v.\+'
" Set Colors
set background=dark
" Show a status bar
set ruler
set laststatus=2
" Set Search options highlight, and wrap search
set hls is
set wrapscan
" File Type detection
filetype on
filetype plugin on
" Enable Spell Checking
set spell
" Enable Code Folding
set foldenable
set foldmethod=syntax
" PHP Specific options
let php_sql_query=1 " Highlight sql in php strings
let php_htmlInStrings=1 " Highlight HTML in php strings
let php_noShortTags=1 " Disable PHP Short Tags
let php_folding=1 " Enable Ability to FOLD html Code
phpcs.vim の 2 つの異なるバージョンを試しましたが、両方で同じ結果が得られました。
バージョン 1 (次の場所にあります: VIM an a PHP IDE )
function! RunPhpcs()
let l:filename=@%
let l:phpcs_output=system('phpcs --report=csv --standard=YMC '.l:filename)
" echo l:phpcs_output
let l:phpcs_list=split(l:phpcs_output, "\n")
unlet l:phpcs_list[0]
cexpr l:phpcs_list
cwindow
endfunction
set errorformat+=\"%f\"\\,%l\\,%c\\,%t%*[a-zA-Z]\\,\"%m\"
command! Phpcs execute RunPhpcs()
バージョン 2: ( Integrated PHP Codesniffer in VIM にあります)
function! RunPhpcs()
let l:filename=@%
let l:phpcs_output=system('phpcs --report=csv --standard=YMC '.l:filename)
let l:phpcs_list=split(l:phpcs_output, "\n")
unlet l:phpcs_list[0]
cexpr l:phpcs_list
cwindow
endfunction
set errorformat+="%f"\\,%l\\,%c\\,%t%*[a-zA-Z]\\,"%m"
command! Phpcs execute RunPhpcs()
これらは両方とも同じ結果を生成します。
私のシステムには phpcs がインストールされており、vim の外部で結果を生成できます。私はちょうどvimについてもっと学んでいます...