How to configure Vim for development in C ++?

I learn C ++ using Vim as an editor in Windows XP, however I found a problem that I listed below.

  • I downloaded and installed c.vim, and this is an important file, however, when I run vim it shows the message C/C++ template file 'C:\Program Files\Vim\vimfiles\c-support/templates/Templates' does not exist or is not readable . How to fix this problem?
  • How do I make vim compile a C ++ STL file?
+6
c ++ windows vim
source share
2 answers

For your first problem. . I suspect that you did not extract all the files in the archive (that c.vim entered). The c.vim documentation (README.csupport) says:

Subdirectories in the cvim.zip zip archive mirror the directory structure that is needed below the local installation directory $ HOME / .vim / for LINUX / UNIX ($ VIM / vimfiles / for Windows)

This means that you need to unzip the entire archive as it is in your vimfiles directory.

The following are some other steps that are described in detail in the documentation.

Regarding the second problem : you need a Makefile for this. If you have never done this before, I suggest using cmake to create a Makefile. You will also need GNU tools for Windows; Cygwin or MinGW are the most popular choice. I do not use them, it's easier to do all this on some * nix :) operating system :).

When done, use :cd (if you are not in your working directory) and :make . Use :cl to display compiler output,: :cn to go to the next error. There are other useful compilation commands. You may find these resources useful:

In addition, I found Nerd Commenter a very useful companion.

I found that Vim acts like an alien on Windows; it is intended for a * nix-like operating system. I think that for him you can create a similar environment and use it mostly successfully, but on some Linux device it’s much easier, because it’s “instantly home”.

Anyway, if you want to stick with Windows, I think you can find a way to accomplish what you want. Good luck.

+10
source share
  • Download Vim and install on your computer.
  • Download c.vim and extract to $Vim\vimfiles\
  • To download MinGW and install it on your computer, make sure you check the C++ Compiler in Select Components.
  • Add C:\MinGW to the Path system variable
  • Edit the _vimrc file, add set makeprg=mingw32-make after the behave mswin
  • Test your Vim with the hello world, use !g++ c:\full_path\filename.cpp -oc:\full_path\output.exe .
+1
source share

All Articles