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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:36:22+00:00 2026-05-25T14:36:22+00:00

I have a long text where some lines need to be repeated later. I

  • 0

I have a long text where some lines need to be repeated later.

I put tags like this in the text:

{F1}text need to be repeated later{/F1}

so I can add multiple {F1}{/F1} to later sections and put the contents of the first line between them.

The problem is that there will be a lot of tags like this like {F2}{/F2} etc… and this pattern matches all of those too:

{\(.*\)}.*{\/\1}

So, I want to search every first occurrence of different tags and replace them on later lines, so when I change the first line and make a substitute again, all of the lines will updated, maybe automatically with an autocmd BufWrite.

How could I do this? I accept any solution, not necessarily using my idea of marking the first lines with {}{/} tags. There will be a lot of tags and I don’t want to do it one-by-one with individual substitute commands.

I tried with this:

:g/{\(.*\)}\(.*\){\/\1}/s/{\1}.*{\/\1}/{\1}\2{\/\1}/

but it says:

E65 Illegal back reference.
  • 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-25T14:36:23+00:00Added an answer on May 25, 2026 at 2:36 pm

    The ReplicateTags() function that is listed below runs a substitution
    command replacing contents of each tag (according to its description in the
    question) with text in the first occurrence of that tag. The substitution
    operates on the whole buffer and processes all of the tags in one pass
    (accepting multiline non-overlapping tags). The function returns a dictionary
    that maps tag names to contents of their first occurrence.

    function! ReplicateTags()
        let dict = {}
        %s/{\([^}]\+\)}\(\_.\{-}\){\/\1}/\=Tag(dict, submatch(1), submatch(2))/ge
        return dict
    endfunction
    
    function! Tag(dict, tag, str)
        let a:dict[a:tag] = get(a:dict, a:tag, a:str)
        return printf('{%s}%s{/%s}', a:tag, a:dict[a:tag], a:tag)
    endfunction
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my application,i have text view with long text. i need text wrapping like
If I for example have <p> some long text </p> on my HTML page,
I have a long text and I'd like to offer the user a reading
I have a very long text and I need to hide everything except the
I need to put text on top of an image, it's exactly like the
I have a long list of domain names which I need to generate some
I have a text file that contains a long list of entries (one on
I have a text file that is pretty long. Any easy way to undo
I have a block of text which occasionally has a really long word/web address
I have an input text that is mapped to a Long property. private Long

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.