The simple cooperation between vim and makefile

Source: Internet
Author: User

Vim as a custom-made editor, it is really very powerful, here I say in programming, using VIM and makefile some of the skills, just personal programming habits;

When you finish editing the source code, want to compile links and other work, you can directly with g++, GCC and other compilers, plus the relevant parameters can be completed, but this does not take full advantage of the advantages of vim itself. Here we use the Quickfix tool, which is carried by vim itself, with the following actions:

1) Edit the makefile document directly in the directory of the source file, as shown below, and save

task.o:main.o my2048.o    g+/-G main.o my2048.o-o task.omain.o:main.cpp    g+-G-C main.cpp -O main.omy2048.o:my2048.h My2048.cpp    g+ +-g-c My2048.cpp-O. my2048.o
Clean
RM *.O

2) directly in the VIM command mode with: Make, you can execute the commands in the Makefile document (the first sentence is the main execution statement, where the files to be used, such as MAIN.O, etc, make will automatically find in the makefile document corresponding generation method (g++-g-c Main.cpp-o MAIN.O);

3) make completed, if there is an error, then back to vim, in the VIM command mode, input Quickfix related commands can appear the window to modify, the main command is as follows:

: CC                Displays verbose error message (: HELP:CC): CP                jumps to previous error (: HELP:CP): CN                jumps to next error (: HELP:CN): cl                 Lists all errors (: HELP:CL): Cw
     If there is a list of errors, open the Quickfix window (: HELP:CW): Col               to the previous old Error List (: Help:col): Cnew            

I often only use: CW,CP, CN; If the modifications are complete, just make a second.
4) in the use of the time, the direct CW recurring changes in the window at the bottom, so here I will every time the Quickfix window on the top, convenient to view, that is, vim command <c-w> plus K (shift+k);

The simple cooperation between vim and makefile

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.