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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:07:18+00:00 2026-06-08T01:07:18+00:00

I was stumbling over a behaviour in Vim’s substitute -command that I can’t really

  • 0

I was stumbling over a behaviour in Vim’s substitute-command that I can’t
really follow:

Given the following line of code that contains the && sequence I wanted to
substitute the && with && and a newline:

return a && b

In my first try I simply used s/&& /&&^M/g (^M was inserted via Ctrl-V
<Enter>
).
This results in the following code:

return a && && 
b

How exactly is the substitution performed to insert the second &&<space>?
I expected the first (and only match) to be &&<space> and this complete match to be
substituted by &&^M?

The question is not about how to perform the correct substitution – I ended up
using the \zs token to reset the start of the match and only insert the
newline.
I just want to understand why exactly the duplication is introduced.

  • 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-08T01:07:20+00:00Added an answer on June 8, 2026 at 1:07 am

    The problem you’re hitting is that the substitute command treats & as a special token in the replacement to mean the matched text. You need to escape it.

    :s/&& /\&\&^M/g
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm stumbling over some basic concepts, that I cannot grasp. I hope, somebody can
Been stumbling me for over an hour now and that means time to ask
Im stumbling upon a problem where i need to retrieve data from the following
I can't believe i'm stumbling on something so simple: - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
While stumbling through the chromium code documentation, I came across this post: http://code.google.com/p/chromium/wiki/UsingGit#Windows If
I have been stumbling over this problem for a while now. I am trying
I'm trying to create a file mapper right now, but stumbling a bit over
I am looking to create a QTcpServer using PyQt that can simultaneously return data
I feel like I'm always stumbling over the language used to distinguish between an
I have a form with over 100 dynamically named fields, that post to a

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.