Vim - Delete column

One of the great advantages of Vim over other editors is that it has various visual modes that allow editing text blocks involving multiple lines.

Today I needed to delete the characters from column 5 to column 10 of a file that were between lines 20 and 30.

An alternative would be to use regular expressions, but in Vim, this can be done in a much less complex way.

Vim has several visual modes:

  • v: --VISUAL--
  • V: --VISUAL LINE--
  • <C-v>: --VISUAL BLOCK--

The latter was the solution to my problem.

  1. Just go to line 20 column 5 (start of the block)
  2. Type ctrl+v
  3. Type 10 (number of lines in the block)
  4. Using the l key or the arrow keys, select up to column 10 (end of the block)
  5. Delete the block using the d command.
Julio Batista Silva
Julio Batista Silva
Data Engineer

I’m a computer engineer passionate about science, technology, photography, and languages. Currently working as a Data Engineer in Germany.

comments powered by Disqus