Display function keys in insert mode

I am trying to display my compile and run commands in F5, it works fine in normal mode with the following:

nmap <F5> :<CU>make<CR>:!%:r.exe<CR>:redraw<CR> 

but when I try to do the same in insert mode:

 imap <F5> :<CU>make<CR>:!%:r.exe<CR>:redraw<CR> 

It just prints F5 characters in my source code.

Is there a way for it to work in both modes?

+4
source share
1 answer

How about this:

 imap <F5> <Esc>:<CU>make<CR>:!%:r.exe<CR>:redraw<CR>i 

Thus, it switches to normal mode, and then back.

+6
source

All Articles