VirtualEdit in Vim

I really like vim, and here’s yet another reason. I can transpose columns in a text table, using visual block mode. As a quick example, let’s say I have a file containing usernames and display names. If I want to switch the order of the columns, here are the steps:

  1. enable virtualedit: set virtualedit=all
  2. move to the upper-left corner of a column I want to select
  3. invoke visual block mode: CTRL-V (CTRL-Q if CTRL-V is mapped to Paste)
  4. move the cursor (h,j,k,l or shift-arrow) to select the column
  5. delete the selection: x
  6. move the cursor to the location where I want to insert the column. (Note that with virtualedit enabled, I can move beyond the actual end of a line)
  7. paste the column: p

More info at vim docs online.

Geoff
Sr. System Administrator at the University of Vermont

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.