Working with Region and Rectangle in Emacs
Posted on April 18th, 2007 at 16:22 by fr3@K

Intro

Emacs 的 region 與 rectangle 是兩種常用的範圍選取方式. 兩者都可以把選取的部份暫存在 kill ring 與 register (Emacs 的 兩種暫存機制) 裡. 通常 register 多被用在暫存 rectangle, 而 kill ring 幾乎都是與 region 一起搭配使用. 這兩種組合用法不一樣. 要是沒有好一點的方法, 要熟悉兩者的操作還真不是件容易的事情.


Marking

選取一塊 rectangle 的方式可以跟選取一塊 region 一樣, 用 M-x set-mark-command (or C-SPACE) 開始. 以移動 point (游標) 的方式標示選擇的範圍. User 給 Emacs 下一個 command 時, point 的位置就是選取標示結束的位置:

選取標示決定了之後, 接下來給的 command 才會決定上圖中選取的範圍. 如果給的是 region 的 command. 選取的範圍就是 region (圖中底色為藍色的部份). 如果給的是 rectangle 的 command. 選取的範圍則是 rectangle (圖中用紅色方塊框起來的部份).

Commands

至少對我而言, 用多數人熟悉的 cut-and-paste 方式, 來類比表列 region 及 rectangle 的 command 會比較容易記憶與使用:

Cut-and-Paste Equivalent Region Command Rectangle Command
Cut M-x kill-region or C-w M-x kill-rectangle or C-x r k
Copy M-x copy-region-as-kill or M-w M-x copy-rectangle-to-register RET or C-x r r RET
Paste M-x yank or C-y M-x yank-rectangle or C-x r y

del.icio.us:Working with Region and Rectangle in Emacs digg:Working with Region and Rectangle in Emacs spurl:Working with Region and Rectangle in Emacs newsvine:Working with Region and Rectangle in Emacs furl:Working with Region and Rectangle in Emacs Y!:Working with Region and Rectangle in Emacs 黑米共享書籤:Working with Region and Rectangle in Emacs 推推王:Working with Region and Rectangle in Emacs
Previous Post
« Permalinks Changed «
Next Post
» MSN i’m, Americans Only »

Zero Comments »

No comments yet.

Comments RSS TrackBack URI

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>