aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Buckley-Houston2017-07-29 11:01:39 +0000
committerThomas Buckley-Houston2017-07-29 11:03:41 +0000
commitab787e11ec79434a3e6fad06f0c44f0af80c50b5 (patch)
tree27d8a728402b1b831cd33328c5d37b3df41df6bf
parent49835ac241224e03fd60ef0a8a3c0364384a6188 (diff)
Toggle `set paste` when pasting
-rw-r--r--autoload/novim_mode.vim16
1 files 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 <C-V> <C-O>"+P
- snoremap <C-V> <C-O>"+P
- cnoremap <C-V> <C-R>"+
+ inoremap <C-V> <C-O>:call novim_mode#Paste()<CR>
+ " The odd <Space><Backspace> here is because one-off Normal Mode commands
+ " don't seem to work as expected when some text is selected. Also just
+ " using <Backspace> on its own seems to cause weird behaviour too.
+ snoremap <C-V> <Space><Backspace><C-O>:call novim_mode#Paste()<CR>
+ cnoremap <C-V> <C-R>"
snoremap <C-C> <C-O>"+ygv
inoremap <C-C> <C-O>"+Y
snoremap <C-X> <C-O>"+xi
@@ -326,6 +329,13 @@ function! novim_mode#PageUp()
endif
endfunction
+function! novim_mode#Paste()
+ set paste
+ execute 'normal! "+P'
+ set nopaste
+ call feedkeys("\<Right>")
+endfunction
+
function! g:novim_mode#StartNoVimMode()
call s:InsertAndSelectionBehaviour()