I'm using a really clever plugin that changes the line number style (relative/normal) contextually. Basically when you enter insert mode you have normal line numbers and when you leave insert mode it switches to relative numbers. A missing feature is to have normal line numbers when your in command-line mode.
Looking at how it is implemented it uses Vim's events system to trigger the change. I've looked but Vim's documentation seems to only offer events on insert enter/leave. (Funny aside: UserGettingBored).
At first I thought of adding
nnoremap : :call MyFunc()<CR>: which works on enter but not on exit. Also relying on a map seems flaky.
How do I trigger a function when the user enters command-line mode (presses :)? And how do I trigger a function when the user leaves this mode (presses enter, ctrlc or esc)?