ZhyFly | 随笔网路

... no pains, no gains!

昨天在用 Emacs 编辑一个文本时遇到了 矩形区域 操作的问题,一行一行的改真是太麻烦了,于是想这个功能好像以前见过,只是当时没觉得有多大用处,现在想起来有的时候还是很有用的,就像一次注释多行的功能一样,只不过这个是在一个矩形区域了,今天稍微整理了下,找到了 rect-mark.el,看了下该文件开头部分的说明,然后把这个文件放到 Emacs 能找到的地方,添加如下代码到 ~/.emacs 文件:

;;; rect-mark.el
;; ~/Emacs/Extensions/rect-mark.el
(require 'rect-mark)
;
;; Use this section in your "~/.emacs" when rect-mark isn't included
;; as an integral part of Emacs. Don't forget to remove the first
;; three columns.
;; Support for marking a rectangle of text with highlighting.
(define-key ctl-x-map "r\C-@" 'rm-set-mark)
(define-key ctl-x-map [?r ?\C-\ ] 'rm-set-mark)
(define-key ctl-x-map "r\C-x" 'rm-exchange-point-and-mark)
(define-key ctl-x-map "r\C-w" 'rm-kill-region)
(define-key ctl-x-map "r\M-w" 'rm-kill-ring-save)
(define-key global-map [S-down-mouse-1] 'rm-mouse-drag-region)
(autoload 'rm-set-mark "rect-mark"
 "Set mark for rectangle." t)
(autoload 'rm-exchange-point-and-mark "rect-mark"
 "Exchange point and mark for rectangle." t)
(autoload 'rm-kill-region "rect-mark"
 "Kill a rectangular region and save it in the kill ring." t)
(autoload 'rm-kill-ring-save "rect-mark"
 "Copy a rectangular region to the kill ring." t)
(autoload 'rm-mouse-drag-region "rect-mark"
 "Drag out a rectangular region with the mouse." t)
;; Use this section in your "~/.emacs" to modify picture mode so that
;; it automatically uses the rect-mark equivalents of many commands.
;; One vision of a better picture mode.
(add-hook 'picture-mode-hook 'rm-example-picture-mode-bindings)
(autoload 'rm-example-picture-mode-bindings "rect-mark"
 "Example rect-mark key and mouse bindings for picture mode.")

其操作就是在普通区域操作的前面加上

C-x r 

比如:

标记: C-x r C-S-@ 
复制: C-x r M-w
剪切: C-x r C-w

当你习惯了 Emacs,你不需要再用别的任何编辑工具了!



Trackback: http://tb.donews.net/TrackBack.aspx?PostId=1141677


[点击此处收藏本文]  发表于2007年03月18日 12:55 PM




正在读取评论……

发表评论

大名:
网址:
验证码
评论 
   

news

logo ;)
   StatCounter

who is FlyZhy

contact

funny

趣闻多多 ...

生成365Key昨日新闻

My Flickr

www.flickr.com
This is a Flickr badge showing public photos from FlyZhy.Org. Make your own badge here.

last posts