3

I use Spacemacs, and for some time I've rebound C-v and M-v to spacemacs/scroll-half-page-down and spacemacs/scroll-half-page-up, respectively, to aid my understanding of the buffer as I move through it.

After a recent update, though, these functions seem to no longer be defined. How can I get them back, or something reasonably similar?

6

I actually managed to find the equivalent functions. They are

  • View-scroll-half-page-forward
  • View-scroll-half-page-backward

So, I've updated my dotfile's user-config section to contain

(global-set-key (kbd "C-v") 'View-scroll-half-page-forward)
(global-set-key (kbd "M-v") 'View-scroll-half-page-backward)

and this seems to work fine!

  • Didn't work for me, I got command-execute: Wrong type argument: commandp, View-scroll-half-page-forward – Shane Creighton-Young Oct 18 '18 at 15:28
  • 2
    @ShaneCreighton-Young You need to add (autoload 'View-scroll-half-page-forward "view") (autoload 'View-scroll-half-page-backward "view") to your init file. This will load the needed view library when you use those commands. – clemera Dec 11 '18 at 15:54
  • @clemera That works! Thank you for your help. – Shane Creighton-Young Dec 11 '18 at 16:50
3

I personally recommend you to use a package named golden-ratio-scroll-screen. You can add melpa to your package-list if you have not.

(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))

and then M-x package-list-packages, search for golden-ratio-,

or go to https://github.com/jixiuf/golden-ratio-scroll-screen to get it.

It will do the following two things, which are to me excellent, maybe also what you want:

  1. Scroll half screen down or up, and
  2. highlight current line before or after scrolling.
  • wow this is an amazing little package :) I actually like this more than default behaviour of scroll-up and scroll-down – Chakravarthy Raghunandan Feb 22 '17 at 12:04
  • Personally I like to highlight the bottom/top line shortly and after that the new position after the scroll, see my blog – clemera Mar 5 at 7:39
2

You can also write pretty simple elisp code to achieve this :-

(defun scroll-half-page-down ()
  "scroll down half the page"
  (interactive)
  (scroll-down (/ (window-body-height) 2)))

(defun scroll-half-page-up ()
  "scroll up half the page"
  (interactive)
  (scroll-up (/ (window-body-height) 2)))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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