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

后端 未结 4 2095
后悔当初
后悔当初 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条回答
  • 2020-12-31 08:57

    Try centered-cursor mode:

    http://www.emacswiki.org/emacs/centered-cursor-mode.el

    If you're using MELPA, it's available by M-x package-install RET centered-cursor-mode.

    0 讨论(0)
  • 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)))
    
    0 讨论(0)
  • 2020-12-31 09:02

    M-x scroll-lock-mode, which could be used to put the Scroll Lock key to good use too:

    (global-set-key (kbd "<Scroll_Lock>") 'scroll-lock-mode)
    
    0 讨论(0)
  • 2020-12-31 09:07

    The EmacsWiki page on SmoothScrolling presents some possible solutions.

    0 讨论(0)
提交回复
热议问题