Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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


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.