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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:19:14+00:00 2026-05-26T19:19:14+00:00

How do you replace inside a replace? I know you can get the current

  • 0

How do you replace inside a replace?

I know you can get the current word under the cursor into the replace, but I want to perform a replace on it before having it as the output.

For example:

  • Having a document that has passed through the clbuttic filter and replacing words that you know have been affected for the worse, such as deinstitutionalization (Hint: Consbreastution of the United States of America). The file also has some words that are properly replaced.
  • Changing o to 0 in Wooloomooloo (and only for that word) throughout a document

A real world example (from my vim history) is being in a Latex document and running

%s/\\begin{table}\[h\]/\\begin{table}\[H\]/c

where I am duplicating the string just to get a minor change.

  • 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-26T19:19:15+00:00Added an answer on May 26, 2026 at 7:19 pm

    Replacing o to 0 is straightforward:

    :s/o/0/g
    

    Perhaps you want to know how to apply it to a (visual) selection?

    :s/\%Vo/0/g
    

    Edit Likely what you want (see comments)

    :%s/\<\zs[Wolm]\+\>\ze/\=substitute(submatch(0), 'o', '0', 'g')/g
    

    What this does:

    • [Wolm]\+ matches sequences consisting of just W,o,l,m
    • \<[Wolm]\+\> matches (independent) words of the same (so, Wooloomooloo, or mooW, Wlomo would all match, but not amool etc).
    • \zs marks the begin of the match for replace, \ze the end
    • \=substitute(submatch(0), 'o', '0', 'g') replaces the match (between \zs and \ze) but subsituting 0 for o

    You can start from this pattern

    • replacing [Wolm]\+ with your actual target
    • adding optional context outside \zs...\ze so you can reduce matches
    • adding \c in the front of the pattern to enable case-insensitive matching
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the code below to replace text inside a div. But I
How can polymorphism replace an if-else statement or Switch inside of a loop? In
I would like to know if I can display a view inside another view
I know this should be simple but I can't make it work. I have
I'm trying to replace certain text inside the div info when an image (which
I'm trying to replace every multiline import inside a Python source file.. So, the
I just wondering how I could replace the second instance of a string inside
trying to use regex to replace any white space with &nbsp;, inside of example
How can I replace lone instances of \n with \r\n (LF alone with CRLF)
I constantly get this error using mako: UnicodeEncodeError: 'ascii' codec can't encode character u'\xe0'

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.