Show scroll bars only when needed.
Enable on-demand-scroll-bar-mode to show the native graphical
scroll bars when the buffer is not fully visible.
This is experimental and hacky. Expect breaking changes.
Clone the repository and put the path in your load path.
Then, require on-demand-scroll-bar in your init file:
(add-to-list 'load-path "/path/to/~on-demand-scroll-bar")
(require 'on-demand-scroll-bar)Enable on-demand-scroll-bar-mode:
(on-demand-scroll-bar-mode 1)Emacs’s built-in scroll-bar-mode conflicts with
on-demand-scroll-bar-mode and should be disabled:
(scroll-bar-mode -1)Or use use-package:
(use-package on-demand-scroll-bar
:load-path "path/to/on-demand-scroll-bar"
:config
(on-demand-scroll-bar-mode 1)
(scroll-bar-mode -1))Optionally, combine it with custom-css to adapt the scroll-bar appearance. https://github.com/florommel/custom-css
Hidden sections of the buffer (e.g., with org or magit) can result in “false positives” (the scroll-bar is shown despite the visible part of the buffer being contained within the window constraints). Narrowed buffers, however, are handled correctly.