I'm trying to write an insert mode mapping for pasting from the system clipboard. I have this:
imap <c-p> <c-o>:set paste<cr><c-r><c-r>+<c-o>:set nopaste<cr>
(Note that this is supposed to work according to this)
However when invoking the key mapping, it doesn't work, it stops short at the set paste part, so I just end up with paste mode enabled.
But if I do all those keys manually then I get what I want...so what's different when the commands are under a keymap? What am I missing to make this work?
I have also tried this:
imap <c-p> <esc>"+gP
This throws a slew of errors about gP being an unknown variable, but the same mapping in normal mode works as expected...so what's different with insert mode mappings?