How to Compile C++ Code Using Vim on Windows?

First, I install Vim (Text Editor) in Typical type, on this Windows 7 laptop. And this user that I'm using is an administrator on this computer but couldn't open file in “Program Files” location for writing with Vim. So I change my :cd current directory to my $HOME.

Note: I already have installed Visual Studio Express for Windows Desktop. I just want learn how to use this.

  1. Can I compile C++ code using Vim in Typical type alone on Windows?
  2. If it's possible, then what's the process for compiling C++ code?

I have hello.cpp file but I can't compile it. I already use :comp gcc and :make and the output is: 'make' is not recognized as an internal or external command,

But when I use :comp msvc and :make, the output is: 'nmake' is not recognized as an internal or external command,

Now, what should I do? If it's not possible using Vim alone, how can I compile using Vim with the compiler on my VS Express for Desktop?

Upvotes: 3

Views: 13993

Answers (2)

Pavel K
Pavel K

Reputation: 3618

Vim is just an editor tool. To compile a program you need a compiler tool chain. The one that Visual Studio use is Microsoft Visual Studio C++ Compiler, so you could use it. Or install and use gcc.

The make file that you are generating is used by make utility to actually compile the code for you. There is a Windows version of this tool.

However I would suggest you to perform minimum steps to compile a c++ program manually for better understanding of the process:

Create source .cpp file -> Create object file with a compiler-> create executable with a linker

Good step-by step instructions for Visual c++ here

If you prefer to use gcc, these are good links how to install and use it on Windows.

Upvotes: 3

Ronak Jain
Ronak Jain

Reputation: 3358

VIM is a great text editing tool,its like an awesome version of notepad.But it's not a compiler,neither has a build in compiler of itself.So In order to compile the program you'll need a separate compiler installed,like You can use MinGW.

See This : How to use MinGW make with Vim on Windows

Upvotes: 7

Related Questions