I tried imap < F9 > :!g++ %
- (without spaces), but it doesn't work.
EDITED: So stupid, I wanted to say map < F9 > :!g++ %
- without spaces...
But I figured out that the spaces are the problem.
This should be what you are looking for:
:map <F9> :!g++ %
imap
is for ignoring the mapping.
Next time you ask a question please provide more details on how exactly it did not work (what output did it have when you pressed F9? did nothing happen?).