junegunn / goyo.vim

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

Disable scrollbar in Goyo mode #189

Closed kflu closed 5 years ago

kflu commented 5 years ago

Scrollbar can be very distracting, especially when gvim is in full-screen mode, and the background is dark:

image

I had to disable it manually with :set go-=r

llinfeng commented 5 years ago

You can use the following to do two things at the same time. It assigns to <localleader>g the following two actions: 1. hide the scroll bar and 2. trigger the :Goyo command.

function! Goyo_Focus()
    setlocal go-=r
    Goyo
endfun
nnoremap <localleader>g :call Goyo_Focus()<CR>

What is left unfinished is to add a counter in the Goyo_Focus function, so that it records the number of calling of the function and will restore the scrollbar upon exiting the "focused" Goyo mode.

llinfeng commented 5 years ago

A better solution goes here. Should have read the ReadMe more closely.

" Reconfigure the entry/exit actions of Goyo
function! s:goyo_enter()
    setlocal go-=r
endfunction
function! s:goyo_leave()
    setlocal go+=r
endfunction
autocmd! User GoyoEnter nested call <SID>goyo_enter()
autocmd! User GoyoLeave nested call <SID>goyo_leave()
" Icing on the cake
nnoremap <localleader>g :Goyo<CR>
kflu commented 5 years ago

A better solution goes here. Should have read the ReadMe more closely.

" Reconfigure the entry/exit actions of Goyo
function! s:goyo_enter()
    setlocal go-=r
endfunction
function! s:goyo_leave()
    setlocal go+=r
endfunction
autocmd! User GoyoEnter nested call <SID>goyo_enter()
autocmd! User GoyoLeave nested call <SID>goyo_leave()
" Icing on the cake
nnoremap <localleader>g :Goyo<CR>

thanks for the tip!

I just feel we could provide a more sensible defaults. Having that config code isn't very user friendly. To provide focus mode I feel Goyou should default to turn off all scroll bars.

llinfeng commented 5 years ago

I bet the scrollbar is there for a reason. One reason could be that the scroll bar on the right is absolutely necessary for "scrolling with your finger" on some touch-screen devices. Should the default be such that there is no scroll bar, it can take one a couple of hours to debug. (Learned this thing in a hard way on a Thinkpad X230T, a couple of years ago.)

Also, the intrusive white strip on the right (the scroll bar) may not be that big in other GUIs ==>

image

image