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