Sibin P. Thomas wrote:
Hi,
Could someone let me know how to quickly compile my current buffer? I want a
key map like
nmap <F5> "xxxxx" to do --> gcc -o current_file.o current_file.c
also another map to make an executable, like
nmap <F5> "xxxxx" to do --> gcc -o current_file current_file.c
Also it would be convenient if this command could give a list of errors like
:make.
Regards,
Sibin
Untested:
:nmap <F5> :!gcc -o %:h.c % >%:h.err 2>&1
:nmap <S-F5> :!gcc -o %:h % >%:h.lst 2>&1
If I didn't goof, these should work regardless of whether the current
file is *.c or *.cpp
(Of course you cannot map two different command to a single shortcut. I
have mapped the compile-and-link operation to Shift-F5)
see ":help :!"
If it doesn't work as-is, see also
:help :execute
:help expand()
:help fnamemodify()
Best regards,
Tony.