📜 ⬆️ ⬇️

Smart make

Most of the vim adapts that use it to work with the code know about such commands as: make and: cw. The first runs make, and the second displays a list of errors.
It so happened that my main working (those that I use at work :)) languages ​​are C and C ++. And it often happens that you need to write a program in one file in order to check some algorithm, function or idea. While writing a makefile for a single file in the scrap, and so I want to use the familiar key combination. Sketched a wonderful solution:
 if filereadable ("Makefile")
	 set makeprg = make \ -j4
	 map <Cb>: make <CR>: cw <CR>
 else
	 map <Cb>: make%: r <CR>: cw <CR>
 endif

As you can see, the point is that just run make when you have a makefile and make filename when absent. make -j4 indicates the launch of four build threads, for dual-core processors it is the most, especially in combination with the -pipe switch for gcc :)

')

Source: https://habr.com/ru/post/40369/


All Articles