Visual C++のプロジェクトをVimでビルドする
以前の設定だと、エラーメッセージを拾えずジャンプも出来なかった。出力内容を確認すると、C#の場合、エラーなどのメッセージに(行,桁)が含まれているのに対して、C++の場合は(行)のみになっている。これくらい同じフォーマットに揃えてくれればいいのになぁ。
ということで以下のように修正して、VC++のプロジェクトも快適にVimでコーディング&ビルド出来るようになりました。
$VIMRUNTIME/compiler/msbuild.vim
if exists("current_compiler") finish endif let current_compiler = "msbuild" if exists(":CompilerSet") != 2 command -nargs=* CompilerSet setlocal <args> endif CompilerSet errorformat= \%E%f(%l):\ error\ %m, " 今回の追加部分 \%W%f(%l):\ warning\ %m, " 今回の追加部分 \%E%f(%l\\,%c):\ error\ %m, \%W%f(%l\\,%c):\ warning\ %m, \%-G%.%# CompilerSet makeprg=MSBuild \\ /nologo \\ /consoleloggerparameters: \NoItemAndPropertyList; \ForceNoAlign;
$VIM/vimrcに記述
autocmd BufNewFile,BufRead *.sln,*.vcproj,*.csproj,*.xaml :set filetype=xml autocmd BufNewFile,BufRead *.sln,*.vcproj,*.cpp,*.hpp,*.c,*.h,*.csproj,*.cs,*.xaml :compiler msbuild autocmd FileType xml :set fileencoding=utf-8 autocmd FileType xml :set encoding=cp932