aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2020-09-14 15:08:34 +0900
committernsfisis <nsfisis@gmail.com>2020-09-14 15:08:34 +0900
commit0f436fa5e5491a03b3369c1980d8d9245f3cae23 (patch)
treea1a2af8dc8bb26e6b6954b6104fa9c1038efb1c0
parent44fe00b8275e8d20871e42917b873ce9aa8001f1 (diff)
downloaddotfiles-0f436fa5e5491a03b3369c1980d8d9245f3cae23.tar.gz
dotfiles-0f436fa5e5491a03b3369c1980d8d9245f3cae23.tar.zst
dotfiles-0f436fa5e5491a03b3369c1980d8d9245f3cae23.zip
Update .vimrc: auto-toggle 'paste'
-rw-r--r--.vimrc19
1 files changed, 19 insertions, 0 deletions
diff --git a/.vimrc b/.vimrc
index 89b20fc..8b5b0f9 100644
--- a/.vimrc
+++ b/.vimrc
@@ -663,6 +663,25 @@ nnoremap <C-r> "
xnoremap <C-r> "
+" Paste clipboard content with 'paste' enabled
+function! s:paste_clipboard_content_with_paste_opt() abort
+ let old_paste = &paste
+ set paste
+ set pastetoggle=<Plug>(pastetoggle)
+ if old_paste
+ return "\<C-r>+"
+ else
+ " 'paste' was off when the function was called. Then, 'paste' will be
+ " disabled via 'pastetoggle'.
+ return "\<C-r>+\<Plug>(pastetoggle)"
+ endif
+endfunction
+
+" Automatically enable 'paste' and disable it after pasting clipboard's
+" content.
+inoremap <expr> <C-r>+ <SID>paste_clipboard_content_with_paste_opt()
+
+
let @j = 'j.'
let @k = 'k.'
let @n = 'n.'