Skip to Content
Practical Vim, 2nd Edition
book

Practical Vim, 2nd Edition

by Drew Neil
October 2015
Intermediate to advanced
356 pages
7h 54m
English
Pragmatic Bookshelf
Content preview from Practical Vim, 2nd Edition
Tip 26Append 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:

KeystrokesBuffer Contents

{start}

Normal mode

 var foo = 1
 var bar = 'a'
 var foobar = foo + bar

<C-v>jj$

Visual-Block

 var foo = 1
 var bar = ’a’
 var foobar = foo + bar

A;

Insert mode

 var foo = 1;
 var bar ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning the vi and Vim Editors, 8th Edition

Learning the vi and Vim Editors, 8th Edition

Arnold Robbins, Elbert Hannah
Modern Vim

Modern Vim

Drew Neil
Learning the vi and Vim Editors, 7th Edition

Learning the vi and Vim Editors, 7th Edition

Arnold Robbins, Elbert Hannah, Linda Lamb

Publisher Resources

ISBN: 9781680501629Errata Page