In regular (non-evil) emacs, if you select a rectangular region and hit C-x r t to run string-rectangle, inserted text is displayed on all the selected lines as you type.

In Vim, if you select a visual-block and hit I, inserted text is only displayed on the top line until you finish by hitting Escape, at which point it inserts the text on all non-empty lines.

I was really hoping that evil-mode would combine the best of both worlds: select a rectangular region, hit I, and inserted text is displayed on all non-empty lines as you type. Unfortunately, it doesn't display the text as you type.

Is there a way to either make evil-insert display inserted text on all non-empty lines or get string-rectangle to respect empty lines?

Edit: I just realized there's also string-insert-rectangle, which is like visual-block I, in that it inserts text along the left edge of the rectangle, whereas string-rectangle is more like visual-block s because it replaces the existing contents of the rectangle with inserted text.

string-insert-rectangle also doesn't show the final results in the buffer until you complete your input, which makes me wonder if there's a reason behind this I haven't thought of.

1 Answer 1


If I well understood evil's source code, it's a matter of implementation. When you hit I with a visual block, the variable evil-insert-vcount is set to the number of lines in that block (and column start position etc.), so evil knows how many times to repeat on those extra lines below the insertion that just started. But, this extra insertion takes place only when exiting from insert state - see function evil-cleanup-insert-state (the only place evil-insert-vcount is actually used). For reference, here's the function description:

"Called when Insert state is about to be exited. Handles the repeat-count of the insertion command."

(where repeat-count refers to both [evil-insert-]count and vcount).

I know this isn't an actual answer, in that I have no idea how and what to modify to make it work as you suggest. Maybe the right place to ask this question would be at the official's evil issue tracker - I know there are many elisp-fu conaisseurs here, but few of them are probably also interested in evil-mode, at least at this level.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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