junegunn / goyo.vim

:tulip: Distraction-free writing in Vim
MIT License
4.52k stars 118 forks source link

Goyo and line number toggle #42

Closed Brixy closed 10 years ago

Brixy commented 10 years ago

Hi!

It often makes sense to toggle between relative and absolute line numbers, i. g. using

autocmd InsertEnter * :set number
autocmd InsertLeave * :set relativenumber

Therefore, I updated goyo.vim as follows.

  augroup goyo
    autocmd!
    autocmd BufWinLeave <buffer> call s:goyo_off()
    autocmd TabLeave    *        call s:goyo_off()
    autocmd VimResized  *        call s:resize_pads()
    autocmd ColorScheme *        call s:tranquilize()
    autocmd InsertEnter * :set nonumber
    autocmd InsertLeave * :set norelativenumber
  augroup END

Do you think this makes sense as a general enhancement?

junegunn commented 10 years ago

At this point I have no plan to change the default settings of Goyo. You should be able to achieve the same using GoyoEnter and GoyoLeave events. Wrap those InsertLeave and InsertEnter autocmds in a custom augroup, clear autocmds of the group in GoyoEnter, and re-register them on GoyoLeave.

Brixy commented 10 years ago

Thanks a lot!

Yes, I tried GoyoEnter/GoyoLeave before, and it works perfectly.

Just thought, this “issue” could be that common, that it made sense implementing it generally.

You can close this topic, of course.

junegunn commented 10 years ago

I believe it's outside the scope of Goyo, but thanks.