Tip 70Act Upon a Collection of Files

So far, we’ve stuck to tasks that were repeated in the same file, but we can play back a macro across a collection of files. Once again, we’ll consider how to execute the macro in parallel and in series.

Let’s start with a set of files that look something like this:

 # ...[end of copyright notice]
 class​ Animal
 # implementation
 end

We’ll wrap the class in a module to end up with this:

 # ...[end of copyright notice]
 module​ Rank
 class​ Animal
 # implementation...
 end
 end

Preparation

Source these lines of configuration to reproduce the examples in this tip:

 set​ nocompatible
 filetype​ plugin indent ​on
 set​ hidden
 if​ has(​ ...

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

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.