From ab787e11ec79434a3e6fad06f0c44f0af80c50b5 Mon Sep 17 00:00:00 2001 From: Thomas Buckley-Houston Date: Sat, 29 Jul 2017 18:01:39 +0700 Subject: Toggle `set paste` when pasting --- autoload/novim_mode.vim | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/autoload/novim_mode.vim b/autoload/novim_mode.vim index f992b3f..9d09d58 100644 --- a/autoload/novim_mode.vim +++ b/autoload/novim_mode.vim @@ -149,9 +149,12 @@ function! g:SetNoVimModeShortcuts() " at the end of a line, pasted text gets put *before* the cursor. set virtualedit=onemore " NB. All these use the system clipboard. - inoremap "+P - snoremap "+P - cnoremap "+ + inoremap :call novim_mode#Paste() + " The odd here is because one-off Normal Mode commands + " don't seem to work as expected when some text is selected. Also just + " using on its own seems to cause weird behaviour too. + snoremap :call novim_mode#Paste() + cnoremap " snoremap "+ygv inoremap "+Y snoremap "+xi @@ -326,6 +329,13 @@ function! novim_mode#PageUp() endif endfunction +function! novim_mode#Paste() + set paste + execute 'normal! "+P' + set nopaste + call feedkeys("\") +endfunction + function! g:novim_mode#StartNoVimMode() call s:InsertAndSelectionBehaviour() -- cgit v1.2.3-70-g09d2