I\'ve recently installed a vim editor in my Windows operating system. I only know the conventional procedure i.e, creating the source file in the editor and running it from the
I assume your version of Vim is windows version and not cygwin version.
First you need to install a compiler, and make sure it's in your PATH.
Also, read the documentation about quickfix window as this is the integrated vim way of compiling. :!make
or :!g++ ...
are not the way to go.
I don't suppose this is the compiler you have as I expect you'd have used Visual Studio in that case. Anyway, IIRC, there is a msdev
compiler plugin you could load with :compiler msdev
, then you should able to run :make
.
Don't hesitate to complete my answer if you see errors.
There is a big advantage: gnumake is properly configured: in the console you could run make foo
, and if you have foo.cpp
or foo.c
and no Makefile
in the current directory, this would compile the monofile project. In all cases, a Makefile
is fine; and it's required with multiple source files.
The big problem: pathnames are not expressed in the same way. They need to be translated. I provide a way to do that in my Build-Tools-Wrapper plugin. Just execute :BTW add cygwin
.
Then from vim, again type :make %<
. That will translate into :make foo
(assuming you're editing foo.cpp
), which translates into make foo
shell wise, which translates into $CXX $CPPFLAGS $CXXFLAGS $LDFLAGS foo.cpp -o foo $LDLIBS
(or something like that).
Note: this means the options can be tweaked with: :let $CXXFLAGS = '-std=c++17 -Wall -Wextra'
BTW, if you have my build-tools-wrapper plugin, you can execute directly :Make
instead of :make %<
, or just
directly, IIRC.
The good news: no need to translate pathnames
The bad news, gnumake isn't correctly configured. This means that in the console make foo
won't work. And consequently, this won't work from Vim.
This time, you'll either need a Makefile
, or you'll need to tweak 'makeprg'
setting. Like for instance :let &makeprg = 'g++ -Wall -Wextra -std=c++17 -o %< %'
and then type simply :make
.