开发者

How to configure Vim for C++ development?

开发者 https://www.devze.com 2022-12-14 15:41 出处:网络
I\'m learning C++ using Vim as an editor on Windows XP, however I found a issue that I have listed below.

I'm learning C++ using Vim as an editor on Windows XP, however I found a issue that I have listed below.

  1. I have downloaded and installed c.vim and it is a essential file, however when I start 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 do i fix this problem开发者_如何学运维?
  2. How would i make vim compile a C++ STL file?


For your first problem: I suspect that you didn't extract all the files in the archive (that c.vim came in). The c.vim documentation (README.csupport) says:

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

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

There are some other steps to follow, detailed in the documentation.

As for your second issue: you need a Makefile to do that. If you have never done this before, I suggest using cmake to generate a Makefile. You will also need GNU tools for Windows; Cygwin or MinGW are the most popular choices. I haven't use them, it is easier to do all this on some *nix OS :).

When done, use :cd (if you are not in your working directory), and :make. Use :cl to list the compiler output, :cn to jump to the next error. There are some other useful commands for compiling. You might find these resources useful:

  • StackOverflow: Recommended plugins for C coding
  • Compiling from Vim
  • C editing with Vim

Also, I found the Nerd Commenter a very useful companion.

I found that Vim acts somewhat like alien on Windows; it is designed for an *nix-like operating system. I think it is possible to craft a similar environment for it, and use it mostly successfully, but it is so much easier to do on some linux, as it is "instantly home" there.

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


  1. Download Vim and install to your computer.
  2. Download c.vim and extract to $Vim\vimfiles\
  3. Download MinGW and install to your computer, make sure that you check C++ Compiler at Select Components.
  4. Add C:\MinGW to system Path variable
  5. Edit _vimrc file, add set makeprg=mingw32-make after line behave mswin
  6. Test your Vim with hello world, use !g++ c:\full_path\filename.cpp -o c:\full_path\output.exe.
0

精彩评论

暂无评论...
验证码 换一张
取 消