From 0f436fa5e5491a03b3369c1980d8d9245f3cae23 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 14 Sep 2020 15:08:34 +0900 Subject: Update .vimrc: auto-toggle 'paste' --- .vimrc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.vimrc b/.vimrc index 89b20fc..8b5b0f9 100644 --- a/.vimrc +++ b/.vimrc @@ -663,6 +663,25 @@ nnoremap " xnoremap " +" Paste clipboard content with 'paste' enabled +function! s:paste_clipboard_content_with_paste_opt() abort + let old_paste = &paste + set paste + set pastetoggle=(pastetoggle) + if old_paste + return "\+" + else + " 'paste' was off when the function was called. Then, 'paste' will be + " disabled via 'pastetoggle'. + return "\+\(pastetoggle)" + endif +endfunction + +" Automatically enable 'paste' and disable it after pasting clipboard's +" content. +inoremap + paste_clipboard_content_with_paste_opt() + + let @j = 'j.' let @k = 'k.' let @n = 'n.' -- cgit v1.2.3-70-g09d2