Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

vim/gvim commands in a shell script

Status
Not open for further replies.

vikramc98406

Full Member level 1
Joined
Nov 30, 2007
Messages
97
Helped
8
Reputation
16
Reaction score
6
Trophy points
1,288
Activity points
1,939
Hi,

I want to execute vim commands from shell script
Below are two examples i can work in exec mode of gvim/vim and can edit a file
:%s/text1/text2/g
:r <filename>

Is there a way to execute the above commands without opening the file either on unix command line or embeded in sh script.
I am also trying to replace a path in file and expand full contents of that.

I am trying to embed in a shell script, can anyone help me

Thanks
vikram
 

If your just planning on using vim/gvim to perform text substitution why not use sed instead? You can shell script that without a problem.
 

Hi Ads-ee,

Instead of suggesting to use sed, can you help me how to use sed to "substitute filepath with its contents" by search and replace method.

I am also curious to know how to use vim exec commands without opening VIM editor, can anyone give me some info.

Thanks
Vikram
 

Hi Ads-ee,

Can you help me in using sed for the below command in VIM, as mentioned in my original post
:r <filename>

Thanks for the link, i will explore more.

Thanks
Vikram
 

Had to play around with the :r <filename> to see what it does. sed won't insert a file into another file as far as I know.

I think you should seriously just use a scripting language like perl/python/tcl to do this task. What you seem to be after is rather more complex than a simple text substitution. You seem to want to automate file editing?
 

Hi Ads-see,

I am looking at a simple solution, I have used vim editing with out opening vim editor.
so not not planning to use complex solution of using other tools.
Thanks for your suggestion, I will work on exploring more.

looking forward for some help from the edaboard community.

Thanks
Chait
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top