Linux Advocacy : Editing multiple files quickly
January 4th, 2009 by RohanStandard Disclaimer
- You can accomplish this in Windows too by installing cygwin or the various tools mentioned in this article.
- This rant is more about the Linux way of doing things, rather than fighting over which OS is better.
- I’m not implying that I’m smarter or better than you. Thats for you to decide.
- There might be better ways in which you can do whatever is outlined in this article. I’m just writing whatever method first came to mind
Editing Multiple Files Quickly
I have a lot of yum repositories defined in my configuration. Often, while installing new software I need to selectively enable or disable some repositories. All the repository definitions are located in *.conf files under a single directory /etc/yum.repos.d

I was looking to install cinelerra - a Linux video editing tool, and for this I had to enable only two yum repositories - kwizart and livna.
The Vim editor can open multiple files. Just specify them as command line arguments.
# vi *.repo
You can use the :n command to go to the next file. :previous for the previous file.
Once I was inside the Vim editor, I immediately ran a search for enabled by typing /enabled, so this word would be higlighted across all files. I can then use the n command to move the cursor to this word.

It was that easy!
- Type n to move the cursor to the word enabled.
- Either enable or disable the repository.
- Type :wn to save and go to next file.
- Go back to step 1
I ran a simple command at the end to verify which repositories were enabled.
# grep -nr enabled=1 *.repo
kwizart.repo:5:enabled=1
livna.repo:12:enabled=1
Only the kwizart and livna repositories were enabled. Mission accomplished!
Now lets see you do this in WIndows.
