diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2019-05-25 19:44:08 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2019-05-25 19:48:50 +1200 |
commit | 6a7de20e33871b8ae2a5270b529dde82d5c4a85b (patch) | |
tree | d300c7b71379c736a717ddefd39c693f47d1e19d | |
parent | Merge branch 'release/v3.3.0' into develop (diff) | |
download | vim-insert-cancel-6a7de20e33871b8ae2a5270b529dde82d5c4a85b.tar.gz vim-insert-cancel-6a7de20e33871b8ae2a5270b529dde82d5c4a85b.zip |
Drop support for Vim 6.x
-rw-r--r-- | doc/insert_cancel.txt | 10 | ||||
-rw-r--r-- | plugin/insert_cancel.vim | 38 |
2 files changed, 13 insertions, 35 deletions
diff --git a/doc/insert_cancel.txt b/doc/insert_cancel.txt index 233e627..9e0deda 100644 --- a/doc/insert_cancel.txt +++ b/doc/insert_cancel.txt @@ -1,4 +1,4 @@ -*insert_cancel.txt* For Vim version 6.0 Last change: 2018 July 12 +*insert_cancel.txt* For Vim version 7.0 Last change: 2019 May 25 DESCRIPTION *insert_cancel* @@ -9,13 +9,7 @@ the buffer was changed by the insert. This is intended as a remap of REQUIREMENTS *insert_cancel-requirements* -This plugin only loads if 'compatible' is not set. It works best if you have -at least |vim7| with |autocmd|, because it leans on the |CursorMoved| event. - -If you don't have |CursorMoved|, the |'[| and |']| marks are used to detect -changes instead. This still works for undoing insert additions, but it won't -restore text that was erased when insert mode was entered with |c| or |s| or -their variants, and it doesn't undo new unindented blank lines. +This plugin only loads if 'compatible' is not set. MAPPINGS *insert_cancel-mappings* diff --git a/plugin/insert_cancel.vim b/plugin/insert_cancel.vim index 8ad47e5..a4595f9 100644 --- a/plugin/insert_cancel.vim +++ b/plugin/insert_cancel.vim @@ -11,7 +11,7 @@ if exists('loaded_insert_cancel') || &compatible finish endif -if v:version < 600 +if v:version < 700 finish endif let loaded_insert_cancel = 1 @@ -34,41 +34,25 @@ endfunction " On cancelling insert mode, if we think we made a change, undo it function! s:Cancel() - - " The flag exists, if it's on, undo - if exists('b:insert_cancel_changed') - if b:insert_cancel_changed - silent undo - endif - - " The flag didn't exist, fall back to marks; if the line number or column - " number of the marks for the last changed text aren't exactly equal, that - " suggests we changed something; undo it - elseif line("'[") != line("']") || col("'[") != col("']") + if get(b:, 'insert_cancel_changed', 0) silent undo endif - - " Redraw the screen to avoid bug with vestigial 'showmode' display - redraw! - endfunction " Set up the hooks described for the functions above, if Vim is new enough to " support all the hooks required -if has('autocmd') && v:version >= 700 - augroup insert_cancel - autocmd! +augroup insert_cancel + autocmd! - " On buffer edit and cursor move, cache the current change number - autocmd BufEnter,CursorMoved * - \ let b:insert_cancel_changenr = changenr() + " On buffer edit and cursor move, cache the current change number + autocmd BufEnter,CursorMoved * + \ let b:insert_cancel_changenr = changenr() - " Function wrappers for entering and leaving insert mode - autocmd InsertEnter * call s:Enter() - autocmd InsertLeave * call s:Check() + " Function wrappers for entering and leaving insert mode + autocmd InsertEnter * call s:Enter() + autocmd InsertLeave * call s:Check() - augroup END -endif +augroup END " Mapping that exits insert mode normally and checks for a change to undo inoremap <silent> <Plug>(InsertCancel) |