Mapping function keys in insert mode

vim

Solution

How about this:

imap <F5> <Esc>:<C-U>make<CR>:!%:r.exe<CR>:redraw<CR>i

So it switches into normal mode and then back again.

Problem

I"m trying to map my compile and run commands to F5, It works fine in normal mode with the following: ``` nmap <F5> :<C-U>make<CR>:!%:r.exe<CR>:redraw<CR> ``` but when I try to do the same in insert mode: ``` imap <F5> :<C-U>make<CR>:!%:r.exe<CR>:redraw<CR> ``` It just prints out the characters F5 into my source code. Is there a way I can have it work in both modes?

Original source