Paste code into a Vim terminal (: set paste vs <cr> * vs ..)

There seem to be several ways to insert code into a Vim terminal without breaking the indent or turning it into a comment:

  • :set paste + regular OS paste
  • Insert using registers *and +for example.<c-o>"+p
  • :set mouse=a + mouse paste

I wonder what is a more practical / more universal approach?

+4
source share
3 answers

The insert from is normalnot indented. I think the easiest, most portable way is <c-o>"+p. As he avoids pastetoggle, he will also work with NeoVim.

Possible indent / indent maps ...

inoremap <silent> <f3> <c-o>"+p
inoremap <silent> <f4> <c-r>+

, . .

...

inoremap <silent> <f3> <c-o>:set paste<cr><c-r>+<c-o>:set nopaste<cr>
inoremap <silent> <f4> <c-o>:set nopaste<cr><c-r>+
+1

, , Vim, * + Vim. gVim, gVim , 'paste'. , - Vim, set paste.

+2

Vim:

set clipboard^=unnamed
set mouse=a

( "*) / Vim .

pastetoggle, . SSH.

0

Source: https://habr.com/ru/post/1620609/


All Articles