Tip 26 | Append After a Ragged Visual Block |
Visual-Block mode is great for operating on rectangular chunks of code such as lines and columns, but it’s not confined to rectangular regions of text.
We’ve already met this snippet of JavaScript:
| var foo = 1 |
| var bar = 'a' |
| var foobar = foo + bar |
Three consecutive lines, each of different length. We want to append a semicolon at the end of each. In Tip 2, we solved this problem using the dot command, but we could just as well use Visual-Block mode:
Keystrokes | Buffer Contents | ||||||
---|---|---|---|---|---|---|---|
{start} Normal mode |
| ||||||
<C-v>jj$ Visual-Block |
| ||||||
A; Insert mode |
|
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.