Two Wrongs

(don't make a right)

Email Quoting with Vim Visual Block Mode

by ~kqr

Block mode selection is not one of the most common modes of selection, but it can be very useful in a few select circumstances. One of those is when you want to insert or delete characters at the start of a bunch of lines. This is the primary use case I have for the visual block mode in Vim – especially when I'm composing emails.

animation of block mode being used as described

To make something a quote, I enter visual block mode with ctrl+v, and then I select the first column of the relevant lines. I press shift-i to enter insert mode in the beginning of the line, I type and press esc to exit insert mode. Bam! Vim has inserted the characters at the start of every selected line.

Deleting the quote characters is even easier. Just enter visual block mode, select the characters and press d to delete.

I used ttyrec with ttygif (link includes instructions) to create the gif recording of my terminal.

If you enjoyed this article, you might like others tagged with