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

前提是你 提交于 2019-11-29 12:05:13

问题


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.

Has anyone got any tips on how to achieve this?

Thanks

Ed


回答1:


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.




回答2:


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)



回答3:


The EmacsWiki page on SmoothScrolling presents some possible solutions.




回答4:


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


来源:https://stackoverflow.com/questions/892378/how-do-i-fix-the-cursor-to-the-middle-of-the-screen-in-emacs-so-that-the-page-m

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!