Skip to content
This repository was archived by the owner on Apr 16, 2026. It is now read-only.
This repository was archived by the owner on Apr 16, 2026. It is now read-only.

Feature request: Support &/$0 in vim substitute replacements #5753

Closed

Description

@nikklassen

I'd like a way to refer to the entire search pattern in a Vim replacement. Currently I have to wrap the whole pattern in brackets and use $1 in my replacement.

Desired behaviour
:%s/foo/namespace.&/ = foo -> namespace.foo
or
:%s/foo/namespace.$0/ = foo -> namespace.foo

Activity

  1. marijnh commented on Jan 22, 2019

    @marijnh
    Member

    (The vim bindings are not being actively maintained, so feature requests are unlikely to get acted on.)

  2. marcelgerber commented on Apr 8, 2019

    @marcelgerber
    Contributor

    @nikklassen Note that you can use $& (:%s/foo/namespace.$&/) to get the whole text. This may not be expected Vim behavior, but still, you can easily use it as a workaround.

  3. nikklassen commented on Apr 8, 2019

    @nikklassen
    Author

    That's exactly what I wanted. It should've occurred to me to try that given how other substitutions work. I really just wanted to use this feature, the exact syntax isn't important to me, and given that Vim bindings aren't being maintained this could probably be closed.

  4. added a commit that references this issue on Jul 5, 2019
  5. ilyakharlamov commented on Jul 5, 2019

    @ilyakharlamov
    Contributor

    fix in #5929

  6. added a commit that references this issue on Jul 5, 2019
  7. added a commit that references this issue on Jan 6, 2020
  8. added a commit that references this issue on Jan 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions