After ":set paste" executed "insert mode's remaps" stop working - VIM (iTerm2)

0

I have this remaps in my .vimrc

inoremap <C-d> <C-o>de
inoremap <C-k> <BS>
inoremap <C-l> <ESC>
inoremap <C-j> <CR>

They does work great, but after :set paste they stop working properly and I'm getting this ^L when I press <c-l> and ^@ when <c-j> is pressed.

If I execute :set nopaste it starts working again as expected.

Is there a way to make it work even with :set paste? or :set nopaste after CMD+V is pressed?

whitesiroi

Posted 2015-10-09T11:59:09.883

Reputation: 175

1'paste' is not meant to be a permanent setting because it prevents mappings from working, among other things. For an easy way to toggle the option, see :help 'pastetoggle' – Heptite – 2015-10-09T16:16:26.463

@Heptite Thank you very much for your comment. I didn't know about pastetoggle. – whitesiroi – 2015-10-10T04:16:20.083

Answers

1

No, as explained in :help 'paste', mappings don't work in "paste" mode.

If you need to copy/paste stuff from/to Vim to/from other programs, get yourself a proper Vim with clipboard support, use "+y and "+p and forget :set [no]paste.

romainl

Posted 2015-10-09T11:59:09.883

Reputation: 19 227

@romaini Thank you very much for your answer. – whitesiroi – 2015-10-10T04:15:48.553