版權聲明

所有的部落格文章都可以在右邊[blog文章原始檔案]下載最原始的文字檔案,並依你高興使用 docutil 工具轉換成任何對應的格式方便離線閱覽,除了集結成書販賣歡迎任意取用,引用

Emacs scroll & Page up Page Down

一直都覺得使用Emacs的時候在scroll的時候怪怪的,總是和 Window上面的Editor不一樣,首先當游標移到畫面頂端或是尾部 的時候Emacs會直接幫你把遊標那一行做畫面置中的動作,這對 於ultraedit用習慣的人來說實在很不方便,常常一下子就不知道 發生甚麼事情,對於寫程式的影響更大,瀏覽程式的思考常常 因此被打斷,然後看程式的時候不時想到這問題十足惱人, 如果您也有相同問題請將下面lisp code加入.emacs中:

;; -------------------------------------
;; Scroll Setting
;; -------------------------------------
(setq scroll-margin 3
    scroll-conservatively 10000)

PageUp & PageDown

Emacs對於這兩顆按鍵榜定的功能是(scroll-up) 和 (scroll-down),其實 沒甚麼太大的問題,但是這又和window上面的編輯器不一樣了,當你 捲動到第一頁再繼續按Page Up鍵, Windows上面的編輯器一般的做法 會幫你把游標移到第一行,有的會幫你移動到第一個字, Emacs卻是 發出逼逼~ 然後甚麼都不做..

如果希望Emacs幫你移動游標到首行或是尾行代替逼逼叫,請加入下面 key bind:

;; ---------------------------------------------
;; Page down/up move the point, not the screen.
;; In practice, this means that they can move the
;; point to the beginning or end of the buffer.
;; ---------------------------------------------
(global-set-key [next]
 (lambda () (interactive)
   (condition-case nil (scroll-up)
     (end-of-buffer (goto-char (point-max))))))

(global-set-key [prior]
 (lambda () (interactive)
   (condition-case nil (scroll-down)
     (beginning-of-buffer (goto-char (point-min))))))

沒有留言:

Related Posts with Thumbnails