vim and makefile
:set makeprg=make
:make shell returned 2 (1 of 1): make: *** No targets specified and no makefile found. Stop. Ok, I have a directory which has Makefile and source code file so when in the directory ( with console ), you could just type make to produce the binary. But how can I do that with vim? Second question: How could u compile single program with vim? Assume in console, you do this: g++ -o bla bla.cpp Now you are editing bla.cpp, but you want to compile it with vim. How do you do that? |
Quote:
|
Quote:
If the Makefile is working you should be able to just type :make in vim to compile it. This of course assumes that your current working directory is the one where the Makefile is located (this works just fine for me, I just verified it with a simple program). The error message seems to hint at you might not be in that directory. To set the compiler and options for a simple c file (as an example), try this: :set makeprg=gcc\ -Wall\ -o\ outname\ % The backslashes are necessary to escape the spaces, and the % character refers to the filename you are currently editing. So The above translates to gcc -Wall -o outname whatever.c. When you have set your makeprg as you wish you can compile using make and show the error list with :cl, hop to the next error line using :cn and so on. Hope that helps. Håkan |
Ok, that works. But I have to launch vim from the source code directory with console. But usually I launch gvim with icon then I open the source code file and the current directory is not source code directory. That means I cannot use "make" command anymore because the current directory is in $HOME directory ( I think ).
How to change the current directory in vim? |
Heh, I had to check it for myself but this works:
:cd /wherever/the/directory/is :make Håkan |
Ok, thank you. But that means I miss GTK+-2.4 feature, that is bookmark of GTK+ file selection. But nothing is perfect in this world.
But how can you run the binary? :./a.out :a.out not working....... |
To execute external commands you need to prepend them with an exclamation mark. :!./test to execute the program "test" located in the current directory.
I don't understand what you mean with the GTK+ bookmark at all. :o Håkan |
If you use GTK+-2.4 version, when you open file with gvim, you have bookmark feature. So you could record what directory are visited very often by you.
But thank you. |
All times are GMT -5. The time now is 05:05 PM. |