Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 4 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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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