Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim remap in paste mode

Tags:

vim

remap

paste

Is there a possibility to remap in paste mode.

For example, I remapped jk to <ESC> in insert mode with inoremap jk <esc>, so I can easily exit normal mode. But when I'm in paste mode with :pastetoggle my remapping does not work anymore. I looked for the help with :help map-modes but could not find anything related to the paste mode.

like image 296
Till Friebe Avatar asked Sep 08 '26 13:09

Till Friebe


2 Answers

From :help 'paste':

[...]
When the 'paste' option is switched on (also when it was already on):
        - mapping in Insert mode and Command-line mode is disabled
[...] 
like image 99
romainl Avatar answered Sep 10 '26 12:09

romainl


One workaround to the fact that remappings don't work in paste mode is to use vim-unimpaired's yo and yOcommands to paste. At least this way leaving insert mode with paste set will also set nopaste and you won't find yourself in paste mode when you don't want to be as much.

like image 38
YPCrumble Avatar answered Sep 10 '26 10:09

YPCrumble



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!