aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-06-30 17:03:26 +1200
committerTom Ryder <tom@sanctum.geek.nz>2018-06-30 17:03:26 +1200
commitc50cc11e48b33187b398f1e9c7f1b1125c7e1d62 (patch)
treeea02b5fa496bb06416718f334ec68aa58d7fb141
downloadvim-insert-timeout-c50cc11e48b33187b398f1e9c7f1b1125c7e1d62.tar.gz
vim-insert-timeout-c50cc11e48b33187b398f1e9c7f1b1125c7e1d62.zip
First commitv0.1.0
-rw-r--r--README.md18
-rw-r--r--VERSION1
-rw-r--r--autoload/insert_timeout.vim15
-rw-r--r--doc/insert_timeout.txt28
-rw-r--r--plugin/insert_timeout.vim28
5 files changed, 90 insertions, 0 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..d2e5702
--- /dev/null
+++ b/README.md
@@ -0,0 +1,18 @@
+insert\_suspend\_hlsearch.vim
+=============================
+
+This plugin leaves insert mode automatically if there is no activity for a
+certain number of seconds, with an `'updatetime'` hook. This is just a plugin
+packaging of Vim tip #1540:
+
+<http://vim.wikia.com/wiki/To_switch_back_to_normal_mode_automatically_after_inaction>
+
+Requires Vim 7.0 or later.
+
+License
+-------
+
+Copyright (c) [Tom Ryder][1]. Distributed under the same terms as Vim itself.
+See `:help license`.
+
+[1]: https://sanctum.geek.nz/
diff --git a/VERSION b/VERSION
new file mode 100644
index 0000000..6e8bf73
--- /dev/null
+++ b/VERSION
@@ -0,0 +1 @@
+0.1.0
diff --git a/autoload/insert_timeout.vim b/autoload/insert_timeout.vim
new file mode 100644
index 0000000..c3da2e6
--- /dev/null
+++ b/autoload/insert_timeout.vim
@@ -0,0 +1,15 @@
+" Set update time to configured variable or default 10 seconds
+function! insert_timeout#SetUpdatetime() abort
+ let g:insert_timeout#updatetime_save = &updatetime
+ let &updatetime = exists('g:insert_timeout_duration')
+ \ ? g:insert_timeout_duration
+ \ : 10000
+endfunction
+
+" Restore update time to globally configured variable
+function! insert_timeout#RestoreUpdatetime() abort
+ if exists('g:insert_timeout#updatetime_save')
+ let &updatetime = g:insert_timeout#updatetime_save
+ unlet g:insert_timeout#updatetime_save
+ endif
+endfunction
diff --git a/doc/insert_timeout.txt b/doc/insert_timeout.txt
new file mode 100644
index 0000000..1922805
--- /dev/null
+++ b/doc/insert_timeout.txt
@@ -0,0 +1,28 @@
+*insert_timeout.txt* For Vim version 7.0 Last change: 2018 June 30
+
+DESCRIPTION *insert_timeout*
+
+This plugin leaves insert mode automatically if there is no activity for a
+certain number of seconds, with an 'updatetime' hook. This is just a plugin
+packaging of Vim tip #1540.
+
+REQUIREMENTS *insert_timeout-requirements*
+
+This plugin is only available if 'compatible' is not set. It also requires the
+|+autocmd| feature.
+
+OPTIONS *insert_timeout-options*
+
+ *g:insert_timeout_duration*
+Set `g:insert_timeout_duration` to the number of milliseconds after which
+insert mode should time out. The default value is 10000 (10 seconds).
+
+AUTHOR *insert_timeout-author*
+
+Written and maintained by Tom Ryder <tom@sanctum.geek.nz>.
+
+LICENSE *insert_timeout-license*
+
+Licensed for distribution under the same terms as Vim itself (see |license|).
+
+ vim:tw=78:ts=8:ft=help:norl:
diff --git a/plugin/insert_timeout.vim b/plugin/insert_timeout.vim
new file mode 100644
index 0000000..2b127e9
--- /dev/null
+++ b/plugin/insert_timeout.vim
@@ -0,0 +1,28 @@
+"
+" insert_timeout.vim: Leave insert mode automatically if there is no activity
+" for a certain number of seconds, with an 'updatetime' hook. This is just a
+" plugin packaging of Vim tip #1540.
+"
+" Author: Tom Ryder <tom@sanctum.geek.nz>
+" License: Same as Vim itself
+"
+if exists('g:loaded_insert_timeout') || &compatible
+ finish
+endif
+if v:version < 700
+ finish
+endif
+let g:loaded_insert_timeout = 1
+
+" Set up actions in a group
+augroup insert_timeout
+ autocmd!
+
+ " Set and restore update time
+ autocmd InsertEnter * call insert_timeout#SetUpdatetime()
+ autocmd InsertLeave * call insert_timeout#RestoreUpdatetime()
+
+ " Cancel insert mode if timeout reached
+ autocmd CursorHoldI * stopinsert
+
+augroup END