Search This Blog


UNIX: Running vi commands in script

Product: vi
Version: All

I was trying to search for ways to run vi scripted commands alike running the vi command manually, but most of the answer I found in Internet are to use shell scripts, awk, or sed. It seems like most people unaware that vi itself can run its command from a script.

So following is an example,

I have following file to do 4 search-replace vi commands



Let say I wanted to execute above vi script inside another SQL script to replace several bind variables

1. vi demo1.sql
2. Type ":so"
3. vi will execute above script and replace all 4 bind variables if found. In Linux, it will display warning message if it found nothing to replace

No comments: