0

This may be trivial but I couldn't find a way to make this mapping work.

I have the following mapping in my .vimrc to compile a file using clang and run it afterwards:

map <F5> :wa \| !clang++ -g -std=c++11 % -o test && ./test : <CR>

I want to add the same mapping in insert mode but I doesn't seem to work. One of the many things I've tried (including wrapping the mapping in a separate function) was:

 imap <F5> <C-o> <F5>

How can I make this mapping work in insert mode?

syntagma
  • 23,346
  • 16
  • 78
  • 134

1 Answers1

1

Remove the space after <C-o>. To get it work, I also needed to use nnoremap instead of map. So this should work:

nnoremap <F5> :wa \| !clang++ -g -std=c++11 % -o test && ./test : <CR>
imap <F5> <C-o><F5>
buff
  • 2,063
  • 10
  • 16