I use the relative line number setting in vim. I would like vim to automatically switch to absolute line numbers when I am in insert mode and back to relative in normal mode. Currently I have tried this code in my vimrc
autocmd InsertEnter * :set number
autocmd InsertLeave * :set relativenumber
Unfortunately this only gets me part of the way there. This toggles on relative numbers the first time I leave insert mode, but will no longer go back to absolute numbers upon entering insert mode again.
Make the vi/vim text editor show or hide line numbers Press ESC key. At the : prompt type the following command to run on line numbers: set number. To turn off line numbering, type the following command at the : prompt set nonumber.
First, do a
set number
Then
autocmd InsertEnter * :set norelativenumber
autocmd InsertLeave * :set relativenumber
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With