Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

The tutorial mentions that the Ex-mode is for batch processing. Since it is a nuisance, rather than a tool, for me, I would like to see some practical examples. Who uses it? Why?

What is the EX-mode for batch processing for?

share|improve this question

migrated from stackoverflow.com Aug 13 '09 at 19:46

This question came from our site for professional and enthusiast programmers.

    
@Masi: link your accounts so migrated posts will be associated with your SU account after migration. –  Greg Hewgill Aug 13 '09 at 20:32
    
@Greg: Thank You. –  Masi Aug 13 '09 at 22:35

2 Answers 2

up vote 20 down vote accepted

Ex-Mode is mostly for performing the same action on a number of files.

Say you have 25 .html files all with:

<a href="/home.html"> ...

Instead of opening each one of those, you could use Ex-mode to change it all to index.html:

vim -E -s bob.html <<-EOF
   :%substitute/home.html/index.html/
   :update
   :quit
EOF
share|improve this answer
4  
A full —and more terse— implementation would be for file in *.html; do vim -es -c '%s/home\.html/index.html/g' -c wq "$file"; done. –  intuited Oct 26 '10 at 6:45

As of the recent 7.3 which as persistent undo support, ex mode and other forms of vim batch processing is superior to other non-vim methods, since it will not clobber the undo history.

Adding: 'persistent undo' if enabled, keeps all changes to a file (up to a limit) in the undo history, across vim editing sessions. If the file is edited by an external program, vim will reset the undo history when detecting by checksum that it has changed. vim -E will allow you to batch-edit a file and the edit will be in the undo history.

share|improve this answer
1  
This seems quite far-fetched, but it's for sure reasonable and clever! +1 –  Tarrasch Jul 31 '12 at 14:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.