How to Use Vim with MSVC and msbuild? How the Developer Command Prompt Commands Can Be Use in Vim?

549 views
Skip to first unread message

Mark Anthony Dungo

unread,
Sep 7, 2013, 11:58:02 PM9/7/13
to vim...@googlegroups.com
On Developer Command Prompt for VS2012 on (Microsoft) Windows, the commands “cl /EHsc filename.cpp” and “cl /clr basicclr.cpp” are used to compile a C++ program and a program that uses .NET classes. What can I do to make those commands compile a program in Vim?

Wikipedia said about MSBuild, “MSBuild is a Microsoft build platform typically used in conjunction with Microsoft Visual Studio. The Visual Studio Application Lifecycle Management also depends on MSBuild to perform the actual team builds via the Team Foundation Server.”

I have VS Express for Desktop on this laptop, does it mean that I already have MSBuild? How can I set my system to allow me to compile with “:compiler msbuild” and “:comp msvc”?

Dan Wierenga

unread,
Sep 9, 2013, 1:48:44 PM9/9/13
to vim...@googlegroups.com

Hi Mark,

On Sat, Sep 7, 2013 at 8:58 PM, Mark Anthony Dungo <ma...@servant.tk> wrote:
On Developer Command Prompt for VS2012 on (Microsoft) Windows, the commands “cl /EHsc filename.cpp” and “cl /clr basicclr.cpp” are used to compile a C++ program and a program that uses .NET classes. What can I do to make those commands compile a program in Vim?
I played around with :makeprg and :compiler for a few minutes to get Vim to use that command, but I couldn't get them to work.  I'm not really all that familiar with using :make and its friends in Vim though (see below).

The Developer Command Prompt sets some environment variables though.  You'll need to make sure that Vim has the same environment, especially that it has cl.exe in the path, or you provide the entire path to cl.exe.

 
I have VS Express for Desktop on this laptop, does it mean that I already have MSBuild? How can I set my system to allow me to compile with “:compiler msbuild” and “:comp msvc”?
 Note that MSBuild will run on your solution file, not your source files.  On my machine, msbuild.exe is installed at C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\msbuild.exe. 
 
You may want to look into the VsVim plugin [1] for Visual Studio.  It makes Visual Studio aware of Vim-like keybindings, including normal and insert modes.  It lets you use the full features of Visual Studio along with the text-editing power of Vim keybindings.  It was enough for me that I didn't bother with figuring out how to make the build environment work with Vim. 



-Dan

David Fishburn

unread,
Sep 9, 2013, 2:00:09 PM9/9/13
to vim_use
On Sat, Sep 7, 2013 at 11:58 PM, Mark Anthony Dungo <ma...@servant.tk> wrote:
On Developer Command Prompt for VS2012 on (Microsoft) Windows, the commands “cl /EHsc filename.cpp” and “cl /clr basicclr.cpp” are used to compile a C++ program and a program that uses .NET classes. What can I do to make those commands compile a program in Vim?

...

This does not address your specific query, but if you have a python enabled Vim you can use:

visual_studio.vim : Vim and Microsoft Visual Studio .NET integration
Author: Michael Graz

I use this, when I use VS.  From Vim you can tell VS to do a build.  It will then open Vim's quickfix window with the compiler errors so you can quickly navigate to the code and make the appropriate changes.


There are mapping to get the current file in VS and open it in Vim (line and cursor preserved) and vise-versa.
 
Since I use VS for code completion, and Vim to edit, I am typically flipping back and forth between them, so these key mappings really help.

HTH,
David

Ben Fritz

unread,
Sep 9, 2013, 3:06:07 PM9/9/13
to vim...@googlegroups.com
On Monday, September 9, 2013 1:00:09 PM UTC-5, David Fishburn wrote:
> On Sat, Sep 7, 2013 at 11:58 PM, Mark Anthony Dungo <ma...@servant.tk> wrote:
>
>
>
> On Developer Command Prompt for VS2012 on (Microsoft) Windows, the commands “cl /EHsc filename.cpp” and “cl /clr basicclr.cpp” are used to compile a C++ program and a program that uses .NET classes. What can I do to make those commands compile a program in Vim?
>
>
>
> ...
>
>
> This does not address your specific query, but if you have a python enabled Vim you can use:
>
>
> visual_studio.vim : Vim and Microsoft Visual Studio .NET integration
>
> http://www.vim.org/scripts/script.php?script_id=864
> Author: Michael Graz
>

I use this also, but it hasn't been updated in a LOOOONG time, and it has stopped working for me for anything but the very basic "get file" and "put file" commands in Windows 7/VS2010. Even these throw errors about the "runtime" terminating in an "unexpected way". Does anyone know of a more maintained location to grab this plugin from?
Reply all
Reply to author
Forward
0 new messages