jeffkreeftmeijer / vim-numbertoggle

Toggles between hybrid and absolute line numbers automatically
https://jeffkreeftmeijer.com/vim-number/#automatic-toggling-between-line-number-modes
MIT License
682 stars 49 forks source link

An option to disable relativenumber #44

Closed wookayin closed 5 years ago

wookayin commented 5 years ago

Great plugin!

It would be great to have an option to disable relativenumber permanently in the current vim session.

Currently :set relativenumber! or set norelativenumber would toggle or turn off the feature, but as we enter the buffer again this loses its effect, i.e. relativenumber gets turned on again. Sometimes one may want to disable it --- a configuration point might be needed.

jeffkreeftmeijer commented 5 years ago

vim-numbertoggle works the other way around. It will turn rnu off in insert mode, and will turn it on in normal mode. The plugin doesn’t touch nu, as having both relative and absolute line numbers on results in hybrid line numbers, and it expects you to set that up yourself.

Removing relative line number toggling would essentially be the same as turning the plugin off. If you’re looking to toggle absolute line numbers, something like this should work:

augroup numbertoggle
  autocmd!
  autocmd BufEnter,FocusGained,InsertLeave,WinEnter * set nu
  autocmd BufLeave,FocusLost,InsertEnter,WinLeave   * set nonu
augroup END