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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:40:28+00:00 2026-06-12T05:40:28+00:00

Objective Yank a line and use it to overwrite some of the lines following

  • 0

Objective

Yank a line and use it to overwrite some of the lines following it.

Assumption

It is preferable in this case to manually select the lines to apply the substitution to. In other words, automated find and replace is not desired.

Analogy

Think of this process as creating a “stamp” from a line of text and going through a list of items—each item being a line of text following the “stamp” line—and deciding whether that line should be overridden using the contents of the “stamp” or not (in the former case, replacing the line with the “stamp”, of course).

This last step of triggering the replacement of the line under the cursor with the contents of the stamp, should be as easy as possible; preferably, as easy as pressing . (repeat last change) or @@ (execute the contents of macro register @).

Issue

The straightforward workflow is, of course, as follows.

  1. Position the cursor on the line to be copied (using movement commands).
  2. Enter line-wise Visual mode (via the V command).
  3. Copy selected text (using the y command).
  4. Manually position the cursor onto the line to be replaced (using movement commands).
  5. Enter Visual mode again to select the text to be replaced (using the V command).
  6. Paste over the selection (using the p command).

However, this approach does not work when the replacement has to be done multiple times. Specifically, replacing the text on step 6 overrides the (unnamed) register containing the line initially copied and intended to be used as a “stamp”.

What I have tried

I have tried using "_y to either yank or delete into the _ register, avoiding the loss of the contents of the stamp, but I am looking for something that ends up being quick and comfortable to type as I manually go through the list and apply replacements where I see fit.

What I would prefer not to use

I would rather not use macros or “remaps” for this, if I can help it.

Illustrative sample file

See the sample starting file below, followed by the desired final stage, for further clarity.

Sample file, starting condition

At this stage, I select the blueberry and make it my “stamp”.

blueberry

apple
banana
coconut
apple
banana
coconut
apple
banana
coconut

Sample file, desired final state

After having moved through the list, I have applied some replacements, “stamping” over some lines, making them the same as the “stamp” blueberry line.

blueberry

apple
banana
blueberry
apple
banana
coconut
apple
banana
blueberry
  • 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-12T05:40:30+00:00Added an answer on June 12, 2026 at 5:40 am

    To make your workflow work as expected, you need to paste from the previous yank register "0, rather than the default register.

    So use Vy (or yy, which is the same) to yank the first line as before, then position the cursor over the line you want to replace, and do

    V"0p
    

    this replaces the current line with the previously yanked text, but doesn’t overwrite the yanked text. I hope I understood you correctly!

    EDIT 1: repeating using a macro

    I was surprised that this operation isn’t repeatable using ., but this is presumably due to the use of visual mode. To repeat the operation using a macro, do this:

    qqV"0pq
    

    The macro can then be repeated by pressing @q or @@.

    EDIT 2: repeating using .

    Here’s an attempt at making it repeatable using . by not using visual mode. After yanking the stamp line and moving the cursor, do this:

    "_S<c-r>0<delete>
    

    which uses the insert mode <c-r> command to insert the contents of register 0. Note that the <delete> is necessary because the stamp line contained a carriage return. If it did not (i.e. yanking using y$ rather than yy) the <delete> could be omitted.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Objective: The intent of this query is to select all of the distinct values
Objective-C categories are extremely useful, but there are some problems with this power. These
[Objective-C] Do you still use Styrofoam balls to model your systems, where each ball
Objective-C newbie question. Given the following (fictional) code: id mysteryObject = [anotherObject mysteriousMethod]; How
In Objective-C, I've used Three20's TTUrlRequest to enable some simple caching of my web
Objective C answers are fine too. This is in C# Monotouch. Currently I am
Objective-J is compiled/transformed into JavaScript directly on the browser. (This is contrast to doing
Objective-C noob here. Why would this: NSString *myString = [NSString alloc]; [myString initWithFormat:@%f, storedNumber];
Objective: To plot a graph(x,y) and move a vertical line over the graph w.r.t
OBJECTIVE: To learn a little more about some technologies I'm familiar with but not

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.