Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

The vim man page describes -s {scriptin} option which allows for automation of file edits. This works fine, but I'd like for vim not to grab the console in this case (and flash the file with edits), but to rather do its stuff silently and invisibly ... similar to a vim -e -s invocation.

Actually, my real need is to automate a file edit with vim in a silent way, so I guess use of vim -e would suffice if it weren't for the fact that I'm not familiar with ex mode (at least not when it comes to bread-and-butter editing commands), and creation of a {scriptin}-format file is just so easy (vim -W). So ... I guess a {scriptin}-format-to-ex-command-format converter would be just as good.

Any ideas?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Is there any reason you couldn't use sed? This is what sed was designed for, and it uses standard regexp string replacement.

Here's an intro to sed: http://www.grymoire.com/Unix/Sed.html

share|improve this answer
    
Actually, yes, very familiar with sed, and this is how I've done things in the past. Just like the idea of editing a file in place without creating temp files/copying/cleaning up. –  Eric Smith Sep 3 '11 at 8:18
1  
If you're using GNU sed you can use sed -i to edit files in place. I do it all the time. –  bahamat Sep 3 '11 at 20:05
    
Ok, now we're talking - thank you, I wasn't aware of that. –  Eric Smith Sep 6 '11 at 4:34
    
There is also ed, which is how you edit files in place when you need to be portable. –  jw013 Jan 6 '12 at 3:03
add comment

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.