Sibin P. Thomas wrote:
Thank a lot to everyone!
I added the following to my _vimrc file to get what I wanted
nmap <C-F9> :Makecompile<CR>
nmap <F5> :Makexec<CR> :!%<.exe<CR>
command Makecompile :se makeprg=gcc\ -o\ %<.o\ % | :make!
command Makexec :se makeprg=gcc\ -o\ %<\ % | :make!
Regards,
Sibin
We're not within a makefile: I don't believe %< will be interpreted.
Passing %<.o (with % interpreted by Vim) to the shell would mean "the
current file, and read stdio from a file named .o". Use %:r.o or, if it
doesn't work,
command Makexec -nargs=0 -bar
\ exe 'set makeprg=gcc\ -o\ '
\ . fnamemodify(expand('%'),':p:r')
\ . '.o\ '
\ . expand('%')
\ | make!
with single quotes to avoid interpretation of backslashes before the
":set" command.
See ":help filename-modifiers"
Best regards,
Tony.