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)?
:
then my range (.,+3
) is more complicated then actual line numbers which I would see ifnorelativenumbers
was set. and so the request that when switching into command mode to swap the relative numbers setting and put it back when leaving. This is how the plugin works for insert/normal mode switching but vim doesn't provide a normal/command event.:
to explain, the idea gets through, though).cmap
or command mapping style), and ex modes. The last (ex) is usually over loaded to mean either the command line from:
or the batch mode fromQ
.:h command-mode
:h command-line-mode