How to do column editing in vim?

Lazer picture Lazer · Aug 7, 2011 · Viewed 86.9k times · Source

Vim is pretty powerful when editing by line - the search/replace tools are modeled to work linewise.

But what if I want to change a particular column across all lines? For example, how can I change the 80th column in my file to a # easily?

Answer

sa125 picture sa125 · Aug 7, 2011

To edit a column, follow these steps:

  1. Stand on the beginning of the column
  2. Press Ctrl+v, then mark across the column you want to edit.
  3. Press Shift+i to insert text at the beginning of the column, Shift+a to append text, r to replace highlighted text, d to delete, c to change... etc.
  4. Hit ESC when done.

I think people (me) sometimes map the column editing keys to Ctrl+Q so it won't collide with visual select line (V) or paste-text if you mapped it as such.