Vim errorformat for Visual Studio

后端 未结 7 1236
南方客
南方客 2021-01-30 17:18

I want to use Vim\'s quickfix features with the output from Visual Studio\'s devenv build process or msbuild.

I\'ve created a batch file called build.bat which executes

相关标签:
7条回答
  • 2021-01-30 17:35

    I have a blog post which walks through all the details of getting C# projects building in Vim, including the error format. You can find it here: http://kevin-berridge.blogspot.com/2008/09/vim-c-compiling.html

    In short you need the following:

    :set errorformat=\ %#%f(%l\\\,%c):\ %m
    :set makeprg=msbuild\ /nologo\ /v:q\ /property:GenerateFullPaths=true
    
    0 讨论(0)
  • 2021-01-30 17:37

    As Simon Buchan mentioned you can use this in your project to generate the full paths in the output:

    <GenerateFullPaths>True</GenerateFullPaths>
    

    But you can make it more portable by adding /property:GenerateFullPaths=true to you makeprg instead of adding the above to your project files.

    :set makeprg=msbuild\ /nologo\ /v:q\ /property:GenerateFullPaths=true\
    
    0 讨论(0)
  • 2021-01-30 17:41

    Copy from question to remove from 'unanswered' list

    set errorformat=\ %#%f(%l\\\,%c):\ %m
    

    This will capture the output for both devenv /Build and msbuild. However, msbuild has one catch. By default, it's output doesn't include full paths. To fix this you have to add the following line to your csproj file's main PropertyGroup:

    <GenerateFullPaths>True</GenerateFullPaths>
    
    0 讨论(0)
  • 2021-01-30 17:42

    I found this question when looking for errorformat for compiling c++ in Visual Studio. The above answers don't work for me (I'm not using MSBuild either).

    I figured out this from this Vim Tip and :help errorformat:

    " filename(line) : error|warning|fatal error C0000: message
    set errorformat=\ %#%f(%l)\ :\ %#%t%[A-z]%#\ %[A-Z\ ]%#%n:\ %m
    

    Which will give you a quickfix looking like this:

    stats.cpp|604 error 2039| 'getMedian' : is not a member of 'Stats'
    

    (with error highlighted) from

    c:\p4\main\stats.cpp(604) : error C2039: 'getMedian' : is not a member of 'Stats'
    
    0 讨论(0)
  • 2021-01-30 17:44

    Try running msbuild instead of devenv. This will open up a ton of power in how the build runs.

    Open a Visual Studio Command Prompt to get your path set up. Then do msbuild MySln.sln /Configuration:Debug.

    See msbuild /? for help.

    0 讨论(0)
  • 2021-01-30 17:59

    I found an even better answer: use :compiler to use built-in efm settings.

    " Microsoft C#
    compiler cs
    " Microsoft Visual C++
    compiler msvc
    " mono
    compiler mcs
    " gcc
    compiler gcc
    

    Note: It also sets the default makeprg. See $VIMRUNTIME/compiler/

    0 讨论(0)
提交回复
热议问题