diff options
Diffstat (limited to 'plugin/insert_cancel.vim')
-rw-r--r-- | plugin/insert_cancel.vim | 29 |
1 files changed, 3 insertions, 26 deletions
diff --git a/plugin/insert_cancel.vim b/plugin/insert_cancel.vim index a4595f9..4221ba4 100644 --- a/plugin/insert_cancel.vim +++ b/plugin/insert_cancel.vim @@ -16,29 +16,6 @@ if v:version < 700 endif let loaded_insert_cancel = 1 -" On leaving insert mode, whether normally or via <Plug>(InsertCancel), check -" if changenr() exceeds the last time we cached it, and flag that a change has -" taken place if it did -function! s:Check() - if changenr() > b:insert_cancel_changenr - let b:insert_cancel_changed = 1 - endif -endfunction - -" On entering insert mode, reset the changed flag and check for a new round of -" changes since insert mode was opened -function! s:Enter() - let b:insert_cancel_changed = 0 - call s:Check() -endfunction - -" On cancelling insert mode, if we think we made a change, undo it -function! s:Cancel() - if get(b:, 'insert_cancel_changed', 0) - silent undo - endif -endfunction - " Set up the hooks described for the functions above, if Vim is new enough to " support all the hooks required augroup insert_cancel @@ -49,11 +26,11 @@ augroup insert_cancel \ let b:insert_cancel_changenr = changenr() " Function wrappers for entering and leaving insert mode - autocmd InsertEnter * call s:Enter() - autocmd InsertLeave * call s:Check() + autocmd InsertEnter * call insert_cancel#Enter() + autocmd InsertLeave * call insert_cancel#Check() augroup END " Mapping that exits insert mode normally and checks for a change to undo inoremap <silent> <Plug>(InsertCancel) - \ <Esc>:<C-U>call <SID>Cancel()<CR> + \ <Esc>:<C-U>call insert_cancel#Cancel()<CR> |