Tip 25Change Columns of Text

We can use Visual-Block mode to insert text into several lines of text simultaneously.

Visual-Block mode is not just useful to us when working with tabular data. Oftentimes, we can benefit from this feature when working with code. For example, take this snippet of (suboptimal) CSS:

 li.one a{ background-image: ​url('/images/sprite.png')​; }
 li.two a{ background-image: ​url('/images/sprite.png')​; }
 li.three a{ background-image: ​url('/images/sprite.png')​; }

Suppose that the sprite.png file has been moved from images/ into a components/ directory. We’ll need to change each of these lines to reference the file’s new location. We could do this using Visual-Block mode as shown in Table ...

Get Practical Vim, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.