How do I fix the cursor to the middle of the screen in Emacs, so that the page moves, not the cursor?

后端 未结 4 2114
后悔当初
后悔当初 2020-12-31 08:30

I\'d like to fix the cursor to the centre line of the screen, so that when I press Ctrl-N or Ctrl-P, the page itself moves up or down, and the cursor stays still.

Ha

4条回答
  •  旧时难觅i
    2020-12-31 09:00

    You can roll your own using the recenter built-in:

    (global-set-key (kbd "C-n")
            (lambda (n)
              (interactive "p")
              (next-line n)
              (recenter)))
    
    (global-set-key (kbd "C-p")
            (lambda (n)
              (interactive "p")
              (previous-line n)
              (recenter)))
    

提交回复
热议问题