Vim errorformat Visual Studio
-
01-07-2019 - |
题
我想用Vim的quickfix设有与输出的视觉工作室的以下建造过程或msbuild。
我已经创建了一批文件,称为建设。蝙蝠其执行下建立这样的:
devenv MySln.sln /Build Debug
在vim我已经指出的:让命令的,批量文件:
:set makeprg=build.bat
当我现在跑:让,建立成功执行,但是错误没有得到分析。所以如果我跑:cl或:cn我只是看到所有的输出以下建立的。我应该看到,只有错误。
我已经尝试一些不同的errorformat设置的,我已经找到各种网站周围的网络,但他们都没有解析出来的错误。正确。这几个我已经试过:
set errorformat=%*\\d>%f(%l)\ :\ %t%[A-z]%#\ %m
set errorformat=\ %#%f(%l)\ :\ %#%t%[A-z]%#\ %m
set errorformat=%f(%l,%c):\ error\ %n:\ %f
当然,我已经试过Vim的默认。
这里是一些例子输出的建立。蝙蝠:
C:\TFS\KwB Projects\Thingy>devenv Thingy.sln /Build Debug
Microsoft (R) Visual Studio Version 9.0.30729.1.
Copyright (C) Microsoft Corp. All rights reserved.
------ Build started: Project: Thingy, Configuration: Debug Any CPU ------
c:\WINDOWS\Microsoft.NET\Framework\v3.5\Csc.exe /noconfig /nowarn:1701,1702 /errorreport:prompt /warn:4 /define:DEBUG;TRACE /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\PresentationCore.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\PresentationFramework.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.DataSetExtensions.dll" /reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.Linq.dll" /reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Xml.Linq.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\UIAutomationProvider.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\WindowsBase.dll" /debug+ /debug:full /filealign:512 /optimize- /out:obj\Debug\Thingy.exe /resource:obj\Debug\Thingy.g.resources /resource:obj\Debug\Thingy.Properties.Resources.resources /target:winexe App.xaml.cs Controller\FieldFactory.cs Controller\UserInfo.cs Data\ThingGatewaySqlDirect.cs Data\ThingListFetcher.cs Data\UserListFetcher.cs Gui\FieldList.xaml.cs Interfaces\IList.cs Interfaces\IListFetcher.cs Model\ComboBoxField.cs Model\ListValue.cs Model\ThingType.cs Interfaces\IThingGateway.cs Model\Field.cs Model\TextBoxField.cs Model\Thing.cs Gui\MainWindow.xaml.cs Gui\ThingWindow.xaml.cs Interfaces\IField.cs Properties\AssemblyInfo.cs Properties\Resources.Designer.cs Properties\Settings.Designer.cs RequiredValidation.cs "C:\TFS\KwB Projects\Thingy\Thingy\obj\Debug\Gui\FieldList.g.cs" "C:\TFS\KwB Projects\Thingy\Thingy\obj\Debug\Gui\MainWindow.g.cs" "C:\TFS\KwB Projects\Thingy\Thingy\obj\Debug\Gui\ThingWindow.g.cs" "C:\TFS\KwB Projects\Thingy\Thingy\obj\Debug\App.g.cs" "C:\TFS\KwB Projects\Thingy\Thingy\obj\Debug\GeneratedInternalTypeHelper.g.cs"
C:\TFS\KwB Projects\Thingy\Thingy\Controller\FieldFactory.cs(14,19): error CS0246: The type or namespace name 'IFieldNothing' could not be found (are you missing a using directive or an assembly reference?)
Compile complete -- 1 errors, 0 warnings
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========
更新: 它看起来像使用msbuild而不是下可能是正确的方式(如每个周杰伦的评论)。
使用msbuild的makeprg将是:
:set makeprg=msbuild\ /nologo\ /v:q
样本输出怎样:
Controller\FieldFactory.cs(14,19): error CS0246: The type or namespace name 'IFieldNothing' could not be found (are you missing a using directive or an assembly reference?)
它看起来像最棘手的部分在这里可以说谎的事实,道路是相对的。csproj文件,不。sln文件,该文件是当前的目录在Vim和谎言的一个目录上。csproj文件。
回答: 我想通了...
set errorformat=\ %#%f(%l\\\,%c):\ %m
这将捕获的输出对这两个下建立和msbuild。然而,更聚焦一个赶上。通过默认,它是输出没有包括完整的路径。为了解决这个问题,你必须添加以下行你csproj文件的主要属性组进行:
<GenerateFullPaths>True</GenerateFullPaths>
解决方案
我有个博客中这走过所有的细节越来越C#项目建立在Vim,包括错误格式。你可以在这里找到它: http://kevin-berridge.blogspot.com/2008/09/vim-c-compiling.html
在短期需要如下:
:set errorformat=\ %#%f(%l\\\,%c):\ %m
:set makeprg=msbuild\ /nologo\ /v:q\ /property:GenerateFullPaths=true
其他提示
复制的问题,以消除从未答复者名单
set errorformat=\ %#%f(%l\\\,%c):\ %m
这将捕获的输出对这两个 devenv /Build
和msbuild。然而,更聚焦一个赶上。通过默认,它是输出没有包括完整的路径。为了解决这个问题,你必须添加以下行你csproj文件的主要属性组进行:
<GenerateFullPaths>True</GenerateFullPaths>
我发现一个更好的答案:使用 :compiler
使用建立在 efm
设置。
" Microsoft C#
compiler cs
" Microsoft Visual C++
compiler msvc
" mono
compiler mcs
" gcc
compiler gcc
注:它还规定默认 makeprg
.看到美元VIMRUNTIME/compiler/
试试运行msbuild而不是下.这将会打开了一吨的力量在如何建立运行。
打开一些工作室的命令迅速得到你的路径,设置。然后做的 msbuild MySln.sln /Configuration:Debug
.
看看 msbuild /?
为帮助。
我发现这个问题时寻找errorformat汇编c++在Visual Studio.上述答复不为我工作(我不用MSBuild或者)。
我想通了,这从 这Vim尖 和 :help errorformat
:
" filename(line) : error|warning|fatal error C0000: message
set errorformat=\ %#%f(%l)\ :\ %#%t%[A-z]%#\ %[A-Z\ ]%#%n:\ %m
这将给你一个quickfix寻找这样的:
stats.cpp|604 error 2039| 'getMedian' : is not a member of 'Stats'
(错误,突出显示的)从
c:\p4\main\stats.cpp(604) : error C2039: 'getMedian' : is not a member of 'Stats'
作为西蒙Buchan提到的可以使用这个项目中产生的全路径的输出:
<GenerateFullPaths>True</GenerateFullPaths>
但你可以使它更便携式通过增加 /property:GenerateFullPaths=true
你的 makeprg
而不是增加上述项目的文件。
:set makeprg=msbuild\ /nologo\ /v:q\ /property:GenerateFullPaths=true\
没有这些errorformats曾在Visual studio2009年v9.0.21022.8个专业版。Using cygwin,不得不叫下从庆典,它由设置makeprg有点棘手(螺丝批文件)。还必须调整我errorformat当下分裂为多个程序和收益的错误信息"1>"或"2>"等:
set autowrite
"2>c:\cygwin\home\user\proj/blah.cpp(1657) : error C2065: 'blah' : undeclared identifier
set errorformat=%.%#>\ %#%f(%l)\ :\ %#%t%[A-z]%#\ %[A-Z\ ]%#%n:\ %m
let prg="devenv"
let makepath=$MAKEPATH
let &makeprg='cmd /c "'.prg.' '.makepath.'"'
我的。更改组的MAKEPATH环境变量使用cygpath转换到DOS兼容的路径:
export MAKEPATH="$(cygpath -d "proj/VC9/some.sln") /build \"Debug\""
如果你有vim6.x你可以使用 :cw 这是好多于clist(尝试寻找错误之中的数以百计的警告,你知道我的意思)。看vim的调整,让我想吐但我在vim天堂!!!好的再见visual studio!感谢您的基本调整pydave+1.