1
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?
The author of the cited userobsessed article is not very experienced with Vim. I use
vim
in a terminal all day, have no problems pasting, and don't jump through all those hoops. To paste from the + register while maintaining the original formatting, use<C-R><C-O>+
. See:help i_CTRL-R_CTRL-O
for more on this. I don't know what's wrong with your second imap--it works fine for me. – garyjohn – 2013-01-31T23:12:34.983I did not see this comment until now, that's strange...did you edit? Anyway, thanks, that's how I ended up solving it. – moljac024 – 2013-02-01T10:10:22.627