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 249373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:25:19+00:00 2026-05-11T21:25:19+00:00

I was just wondering if anyone could help out with how to do the

  • 0

I was just wondering if anyone could help out with how to do the following using vi.

I have a text file and it might contain something like

start of text file:
--something1.something2--
--anotherThing1.something2--
end of text file:

If I want to take this line and convert it by way of searching for anything matching the first occurrence of [A-Za-z0-9] copy that to the buffer then append it on the same line to before the first occurrent of —

start of text file:
--something1.something2.something1--
--anotherThing1.something2.anotherThing1--
end of text file:

Is there a single VI command to do this?

Cheers
Ben

  • 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-05-11T21:25:19+00:00Added an answer on May 11, 2026 at 9:25 pm
    :%s/--\([a-zA-Z0-9]*\).\(.*\)--/--\1.\2.\1--/gc
    

    or without asking confirmation for every replace:

    :%s/--\([a-zA-Z0-9]*\).\(.*\)--/--\1.\2.\1--/g
    

    will produce:

    --something1.something2.something1--
    --anotherThing1.something2.anotherThing1--
    

    from:

    --something1.something2--
    --anotherThing1.something2--
    

    This is if you want to copy the first word after ‘–‘ up to first ‘.’ and append ‘.’ and word found before the last ‘–‘.

    Using vim.

    RE COMMENTS:

    Someone mentioned that it will not work when there are multiple words and so on.
    I tested it on the following:

    start of text file:
    --something1.something2.something3.something4.something5.something6--
    --anotherThing1.something2.anotherThing3.anotherThing4.anotherThing5--
    end of text file:
    

    after replace with the above expression:

    start of text file:
    --something1.something2.something3.something4.something5.something6.something1--
    --anotherThing1.something2.anotherThing3.anotherThing4.anotherThing5.anotherThing1--
    end of text file:
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was just wondering if anyone could help me create a mysql function UUID_SHORT()
Just wondering if anyone could help me with this. I'm new to actionscript, and
I was wondering if anyone could help with this. Let' say I have a
I was wondering if anyone could help me out with this. I am running
Was wondering if anyone could help me out here. I don't dont much with
Hi Guys just wondering if you could help, I have a page in C#
I'm just wondering if anyone could help me change the position of a button
I was wondering if anyone could help me out with finding a simple regular
I was wondering if someone can help out. Im just getting into using migrations
I’m just wondering if anyone’s come across or could recommend an IDE that’s capable

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.