Reputation: 935
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?
Upvotes: 5
Views: 1731
Reputation: 20620
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.
Upvotes: 6