Change all characters in a column over multiple lines

Lennart Koopmann picture Lennart Koopmann · May 6, 2011 · Viewed 14.3k times · Source

I'm not sure how to explain what I'd like to do, but I've seen this in Textmate and it was quite useful. Let's say I have this text:

:aa => foo,
:ab => foo,
:ac => foo,
:ad => foo

Now I want to select all first characters of the keys (the 4 'a' in the lne) and remove them, so that the result looks like this:

:a => foo,
:b => foo,
:c => foo,
:d => foo

Some kind of visual mode accounting columns not lines.

Answer

John Kugelman picture John Kugelman · May 6, 2011

Use Ctrl+V to enter blockwise visual mode. You can then select a block of text using the normal movement keys and press x to delete it. I will perform a multi-line insert.

See :help ^V and :help visual-operators in vim for full details.