When visually selecting rectangles with C-v in evil, the point is not allowed to pass the end of line.

This is in contrast with:

  • rectangle-mark-mode
  • cua-rectangle-mark-mode

Both of which allow the point to pass the EOL. (Although evils behavior is correct vim emulation)

Is there any way I can bring this functionality to evil?

  • Does the behaviour change if you customize evil-move-cursor-back or evil-move-beyond-eol? – wasamasa Aug 15 '15 at 18:02
  • @wasamasa no, sadly. evil-move-beyond-eol only lets you move one character past eol. :/ – PythonNut Aug 15 '15 at 18:03
  • I'm pretty sure there was another question mentioning Evil and overlays as a possible solution for this problem... – wasamasa Aug 15 '15 at 18:12
  • AFAIK it is not possible with evil. In colemak-evil it seems there is an option for set = virtualedit=block (which in vim does exactly you are asking) but I was not able to implement. So the only option is to switch to Emacs state and use rectangle-mark-mode as you already stated. – Enrico Pirani Aug 15 '15 at 18:29
  • Judging by cua-rect.el ` (I couldn't get rectangle-mark-mode to do the right thing) this is possible to do by adding a cursor property with a number indicating the place where the cursor should be inside the string used as after-string for the overlay making up the final line of the rectangle. – wasamasa Jan 20 '16 at 10:30

You'd be better off creating an evil key map for one of the rectangle modes.

The macro evil-define-key allows you to bind to key maps in evil style.

(evil-define-key 'normal key-map-name "key" 'function)

Also you can add binding to the evil global map,

(evil-global-set-key 'normal "key" 'function)

You may like this hydra for use with rectangle-mark-mode, which will work in a similar way to evil / vim.


I'd recommend you play with the different rectangle modes and decide which one you like best, and then make the key map bindings as you need them / see fit. There's also https://github.com/zk-phi/phi-rectangle - Personally I use CUA Rectangle mode, it has a lot of features, although I think navigational bindings are a bit strange/inconsistent.

It's also up to you how you decide to invoke whichever rectangle mode, one option I think makes sense is to have it available in the Visual mode map.

  • And how would I do that? – PythonNut Nov 21 '15 at 4:53
  • @PythonNut I can add more detail if you need it. – ocodo Nov 21 '15 at 5:09

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.