Gvim has a default behavior where it always shows a scrollbar on all buffers at all times.

Is there a way to make the scrollbar visible only if the document is larger than the frame?

link|improve this question
feedback

1 Answer

up vote 3 down vote accepted

Put this in one of your startup files, ~/.vimrc, ~/.gvimrc, ~/_vimrc or ~/_gvimrc, to add or remove the right scrollbar option (r) from guioptions (abbreviated go).

au VimEnter * if line('$') > &lines | set go+=r | else | set go-=r | endif
au VimResized * if line('$') > &lines | set go+=r | else | set go-=r | endif

Those autocommands don't cover all the events that might cause the buffer size to exceed the window size, but it gives you the idea. See

:help autocommand-events

for more.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.