3

Is it possible to select a column (rectangular) region with the mouse in emacs?

A simple yes or no will be helpful to me at this point.

Here are more details:

Column editing is possible in emacs. And it is very easy with cua-mode enabled.

Here are my references for this:

But I also wonder if I can do it with the mouse. I want to select the columns entirely with the mouse (like Scite or Geany can do). Is that possible in emacs?

Edit: New info. The CUA-mode documentation says,

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.

When I try to hold down shift and use the mouse, as soon as I click (before I can even drag), I get a dialog popup. Rather than paste an image of the dialog, I'll type out what the dialog says:

  • Change default buffer face
  • Change buffer font...
  • Increase buffer text size
  • Decrease buffer text size
  • Result to default

I'm new to emacs so I don't recognize this dialog, and I don't know why my shift-click action brings it up instead of doing what (I think) the cua-mode docs say should happen when I shift-click/drag. I'm using Kubuntu 12.04 and emacs v24.

  • Have you tried google first? – Tom Mar 31 '12 at 18:44
  • @Tom - have you read the meta-stack-overflow or FAQs about appropriate answers here? That's not one of them from what I understand. (I'm not an expert on the subject tho.) – MountainX Mar 31 '12 at 20:08
  • Maybe I need to start here: is it possible to select rectangular region with mouse? A simple yes or no will be valuable to me at this point. – MountainX Mar 31 '12 at 21:09
  • Not as satisfying, but you can also start by selecting a normal region with your mouse, then press CTRL-ENTER to turn it into a rectangular region. – teadotjay Jul 12 '16 at 15:38
2

try this:

(require 'cua-rect)
(defun hkb-mouse-mark-cua-rectangle (event)
  (interactive "e")
  (if (not cua--rectangle)
  (cua-mouse-set-rectangle-mark event)
(cua-mouse-resize-rectangle event)))

(require 'cua-base)
(global-unset-key (kbd "<S-down-mouse-1>"))
(global-set-key (kbd "<S-mouse-1>") 'hkb-mouse-mark-cua-rectangle)
(define-key cua--rectangle-keymap (kbd "<S-mouse-1>") 'hkb-mouse-mark-cua-rectangle)
  • Could you please include an explanation of this code? – N.N. Apr 1 '12 at 13:08
  • Yes, an explanation would help along with instructions, please. – MountainX Apr 1 '12 at 16:58
  • Still waiting on some explanation and instructions. I'd like to accept an answer to this question. – MountainX May 6 '12 at 16:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.