aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-07-11 16:44:24 +1200
committerTom Ryder <tom@sanctum.geek.nz>2019-07-11 16:44:24 +1200
commit7de7e84a3c63a4b66e085ad4fb42d3e0b202c0fb (patch)
tree56289ad1a753641fb454dc9fe1fe14aa7a647b77
parentMerge branch 'release/v0.4.0' (diff)
parentBump VERSION (diff)
downloadvim-paste-insert-7de7e84a3c63a4b66e085ad4fb42d3e0b202c0fb.tar.gz
vim-paste-insert-7de7e84a3c63a4b66e085ad4fb42d3e0b202c0fb.zip
Merge branch 'release/v1.0.0'v1.0.0
* release/v1.0.0: End paste mode on TextChanged too Improve comments
-rw-r--r--VERSION2
-rw-r--r--autoload/paste_insert.vim19
-rw-r--r--doc/paste_insert.txt14
3 files changed, 26 insertions, 9 deletions
diff --git a/VERSION b/VERSION
index 1d0ba9e..3eefcb9 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.4.0
+1.0.0
diff --git a/autoload/paste_insert.vim b/autoload/paste_insert.vim
index 946e09a..5b26875 100644
--- a/autoload/paste_insert.vim
+++ b/autoload/paste_insert.vim
@@ -9,11 +9,22 @@ function! paste_insert#() abort
autocmd User Start
\ call s:Start()
- " When starting insert mode, add completion hook for when we leave
+ " On insert mode start, add leaving hook to complete operation
autocmd InsertEnter *
\ autocmd paste_insert InsertLeave *
\ doautocmd paste_insert User Complete
+ " Text changed outside insert mode, complete operation
+ if exists('##TextChanged')
+ autocmd TextChanged *
+ \ doautocmd paste_insert User Complete
+ else
+ autocmd CursorMoved *
+ \ if changenr() > b:paste_insert_changenr
+ \| doautocmd paste_insert User Complete
+ \|endif
+ endif
+
" User waits too long in normal mode, timeout
autocmd CursorHold *
\ doautocmd paste_insert User Timeout
@@ -38,6 +49,9 @@ let s:cancel_keys = get(g:, 'paste_insert_cancel_keys', ['<C-C>', '<Esc>'])
" Start the paste: remap any cancel keys, set 'paste'
function! s:Start() abort
+ if exists('##TextChanged')
+ let b:paste_insert_changenr = changenr()
+ endif
for key in s:cancel_keys
if maparg(key, 'n') ==# ''
execute join(['nnoremap', key,
@@ -51,6 +65,9 @@ endfunction
" Stop the paste: unset 'paste', restore prior function of cancel key
function! s:Stop() abort
+ if exists('##TextChanged')
+ unlet b:paste_insert_changenr
+ endif
set nopaste paste?
for key in s:cancel_keys
execute join(['nunmap', key])
diff --git a/doc/paste_insert.txt b/doc/paste_insert.txt
index 68f1ef9..35f1189 100644
--- a/doc/paste_insert.txt
+++ b/doc/paste_insert.txt
@@ -1,15 +1,15 @@
-*paste_insert.txt* For Vim version 7.0 Last change: 2019 Jun 23
+*paste_insert.txt* For Vim version 7.0 Last change: 2019 Jul 11
DESCRIPTION *paste_insert*
This plugin implements a method for setting paste mode with the 'paste' option
-for only the duration of the next insert operation, to avoid the hassle of
-forgetting to unset the option after inserting.
+for only the duration of the next insert operation or normal mode change, to
+avoid the hassle of forgetting to unset the option after inserting.
-It includes a timeout if insert mode isn't entered within 'updatetime'
-seconds, or if the user navigates away from the buffer or window. It can also
-be cancelled in normal mode with CTRL-C or Escape. These keys can be changed
-if they are already mapped or otherwise unsuitable.
+It includes a timeout if the text isn't changed and insert mode isn't entered
+within 'updatetime' seconds, or if the user navigates away from the buffer or
+window. It can also be cancelled in normal mode with CTRL-C or Escape. These
+keys can be changed if they are already mapped or otherwise unsuitable.
REQUIREMENTS *paste_insert-requirements*