RectangleMark

For another rectangle selection mode that tries to unify rectangle and normal selection operations, try CuaMode (which is part of Emacs, unlike this package).

Based on the Commentary of the file:

The packages makes it possible to highlight the region between point and mark as a rectangle, before you operate on a rectangle.

For example, you can set the mark in preparation for a rectangle command with ‘C-x r C-SPC’, watch the highlighted rectangle grow as you move the TextCursor to the other corner, and then issue the command and the rectangle disappears. Or if point and mark are already set but you want to see what the region would look like as a rectangle, try ‘C-x r C-x’ which exchanges point and mark and makes the highlighted region rectangular.

The default Emacs key-bindings put ‘point-to-register’ on ‘C-x r C-SPC’ but since that command it is already on ‘C-x r SPC’ and since it is irresistably intuitive to put ‘rm-set-mark’ on ‘C-x r C-SPC’, I have taken the liberty of recommending that you override the default key-bindings.

You can also kill or copy rectangles onto the kill ring which is convenient for yanking rectangles into ordinary buffers (i.e. ones not in picture mode) and for pasting rectangles into other window system programs (e.g. xterm). These keys are by default bound to ‘C-x r C-w’ and ‘C-x r M-w’ by analogy to the normal kill and copy counterparts.

Finally, there is mouse support for rectangle highlighting by dragging the mouse while holding down the shift key. The idea is that this behaves exactly like normal mouse dragging except that the region is treated as a rectangle.

You can get it here:

In order to use it, put the file in your LoadPath and add the following to your ~/.emacs:

    (global-set-key (kbd "C-x r C-SPC") 'rm-set-mark)
    (global-set-key (kbd "C-x r C-x") 'rm-exchange-point-and-mark)
    (global-set-key (kbd "C-x r C-w") 'rm-kill-region)
    (global-set-key (kbd "C-x r M-w") 'rm-kill-ring-save)
    (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)

Emacs 24.4 and later now include something similar: Rectangle Mark mode. After a region is active, type ‘C-x SPC’ to toggle it on and off.


CategoryRegion