0

I want to do :set paste, paste, :set nopaste in one keyboard shortcut in insertmode (<C-r>*)

In visualmode, with vnoremap p "+p works with no indent. But in insertmode, this <C-r>* gives indent. How I can make <C-r>* work without indent?

0

2 Answers 2

4

There's Ctrl-RCtrl-O combo in insert mode (see :h i_CTRL-R_CTRL-O).

If setting :h 'paste' is needed, here are the mappings to do this (kind of emulating tpope/vim-unimpaired plugin):

    nnoremap <silent>[op :setl paste<Bar>au InsertLeave * ++once setl nopaste<CR>O
    nnoremap <silent>]op :setl paste<Bar>au InsertLeave * ++once setl nopaste<CR>o
    nnoremap <silent>yop :setl paste<Bar>au InsertLeave * ++once setl nopaste<CR>S
1
  • inoremap <C-R> <C-R><C-O> in .vimrc seems a good option as well.
    – Quasímodo
    Dec 27, 2020 at 23:59
1

I don't know if there is a setting for that but with the :set paste and :set nopaste commands you can do this mapping:

:inoremap <silent> <C-R>* <Esc>:set paste<CR>i<C-R>*<Esc>:set nopaste<CR>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.