diff options
author | =?UTF-8?q?Magnus=20Gro=C3=9F?= <magnus.gross@rwth-aachen.de> | 2021-09-12 13:39:55 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-09-12 13:39:55 +0200 |
commit | f1e8876fa2359b572d262772747405d3616db670 (patch) | |
tree | 1b33a32bccaa4522f14f2aad8ee8044295635d0b /runtime/doc/autocmd.txt | |
parent | 464393a6961d9b9de2bfe9c05f8e2ae5bdec0293 (diff) |
patch 8.2.3430: no generic way to trigger an autocommand on mode changev8.2.3430
Problem: No generic way to trigger an autocommand on mode change.
Solution: Add the ModeChanged autocommand event. (Magnus Gross, closes #8856)
Diffstat (limited to 'runtime/doc/autocmd.txt')
-rw-r--r-- | runtime/doc/autocmd.txt | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt index 63d166dcf9..4d18b788e5 100644 --- a/runtime/doc/autocmd.txt +++ b/runtime/doc/autocmd.txt @@ -366,6 +366,8 @@ Name triggered by ~ |InsertCharPre| when a character was typed in Insert mode, before inserting it +|ModeChanged| after changing the mode + |TextChanged| after a change was made to the text in Normal mode |TextChangedI| after a change was made to the text in Insert mode when popup menu is not visible @@ -925,7 +927,22 @@ MenuPopup Just before showing the popup menu (under the i Insert c Command line tl Terminal - *OptionSet* + *ModeChanged* +ModeChanged After changing the mode. The pattern is + matched against `'old_mode:new_mode'`, for + example match against `i:*` to simulate + |InsertLeave|. + The following values of |v:event| are set: + old_mode The mode before it changed. + new_mode The new mode as also returned + by |mode()|. + When ModeChanged is triggered, old_mode will + have the value of new_mode when the event was + last triggered. + Usage example to use relative line numbers + when entering visual mode: > + :autocmd ModeChanged *:v set relativenumber +< *OptionSet* OptionSet After setting an option. The pattern is matched against the long option name. |<amatch>| indicates what option has been set. |