sethmason.com The internet resource for all things Seth Mason.

Posted:
Sep 27 2007 @ 8PM

Tagged:

Vim Tip: Select Column

How many times have you wanted to replace a column of text with something. With vim it’s easy. Just use CTRL-V to select a column using a visual block.

Once it’s selected, you can do a search and replace, yank, cut and other actions. For example, here’s the keystrokes to change a column.

  • Put cursor and beginning of text to select
  • Press CTRL-V to begin select of the column
  • When you reach the end of your select, type ‘c
  • Type the new text. Note that this will only replace the first instance.
  • Now hit <ESC><ESC>. All the text has been changed!

The same thing works with plain old ‘v‘ (select character by character) and SHIFT-V (select by line).

Happy vimming!

AddThis Social Bookmark Button

No comments yet.

I've left comments off for this article, but if you've got something add or say, feel free to send me an email.