Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7895975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:46:27+00:00 2026-06-03T07:46:27+00:00

I want to do the following for multiple files using Vim: Copy all text

  • 0

I want to do the following for multiple files using Vim:

  1. Copy all text in each file
  2. Replace some text
  3. Paste the copied text at the end of the each file
  4. Replace some other text

Here are my commands for one file:

:%y
:%s/old1/new1/g
:G
:P
:%s/old2/new2/g

Can anybody tell me the syntax to do so? Especially that I’m new to Vim!

I found out that argdo can execute commands on multiple files. I found many examples to use argdo in replacing text, but I couldn’t find the syntax to use argdo with :%y, :G, or 😛

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T07:46:28+00:00Added an answer on June 3, 2026 at 7:46 am

    Like @ib mentioned, I’d do this with ex commands1

    :argdo %y | %s/old1/new1/g | $pu | %s/old2/new2/g
    

    There’s also a good chance that you might want to operate on exclusive ranges (do the first substitution only on the first part, and the second only on the second):

    :argdo $mark a | %co$ | 1,'a s/old1/new1/g | 'a,$s/old2/new2/g
    

    To allow non-matching substitutions, add s///e and add silent! to make operation much faster in the case of many files.

    :silent! argdo $mark a | %co$ | 1,'a s/old1/new1/ge | 'a,$s/old2/new2/ge
    

    1 (note that argdo expects an Ex command list by default. You’d use e.g. argdo norm! ggyG to use normal mode commands)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want the following functionality using php I have a csv file. Each file
I am having few excel files where each file have multiple workbooks. Assume following
I've been using the following snippet to include multiple files: foreach(glob(APP_PATH.libs/*.php) as $path) {
I have the following situation: <input id=upload_trigger_btn type=file name=files[] multiple> <a type=submit class=button-normal-12px-ffffff href=#><span>Add
I'm using domDocument to parse some HTML, and want to replace breaks with \n.
I had a question using Perl's readdir(). I want to gather all the files
I want to store some fragments of an XML file in separate files. It
We have multiple war files packaged in an ear file. Some of the wars
I have huge routes.rb file and I want to split into multiple manageable files.
i want the following functionality. input : this is test <b> bold text </b>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.