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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:36:46+00:00 2026-05-17T23:36:46+00:00

I guess, the problem is pretty common. Let’s say, we have a source file

  • 0

I guess, the problem is pretty common. Let’s say, we have a source file and wish to replace some string with another string.

Usually, I use the following command:

:%s/test/testValue/gc

But, what if the string is pretty long and we need just to touch it up? It is boring to type something like that:

%s/someLongAndDirtyString/somelongAndDirtystring/gc

Is it possible to place a cursor on someLongAndDirtyString word, press some magic key and get the following in the last line?

%s/someLongAndDirtyString/someLongAndDirtyString/gc

Then we may change the new string a bit and proceed with replacing.

Sure, it is just an idea. Please, provide me with the best way of doing such replacements.

Thanks

  • 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-17T23:36:46+00:00Added an answer on May 17, 2026 at 11:36 pm

    You might be interested in this answer I gave on how to use registers, but here are four methods to do that:

    Method 1

    While editing a command, hit CTRLR then CTRLW to insert word under the cursor.

    Also see :help c_CTRL-R

    Method 2

    Go to your word, hit *, and do :%s//replacement/g. When no search pattern is used, last search pattern, taken from register @/, is used.

    Method 3 (you will probably like that one)

    Do a :nnoremap <f12> :%s/<c-r><c-w>/<c-r><c-w>/gc<c-f>$F/i (ctrl-f is determined by the ‘cedit’ option)

    You can put this mapping into your .vimrc.
    This will map the F12 key to what you want, and your cursor will be left where you want.

    Method 4

    Go to your word, hit *, and do :%s//CTRLR,//gc
    CTRL-R then / inserts contents of your search register.

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

Sidebar

Related Questions

I am pretty new in python, and I have a problem I don't know
I guess, the following is a standard problem on every school or university: It
I guess it should be a common technique, However, I tried the following two
I guess the topic says it. I have tried googling this, but havent gotten
I guess I have been using the Web Site model ever since .NET 2.0
Some student asked this on another site, but got no answers. I had a
I'm having the following problem: I have a ListActivity, its ListView is composed by
I have strange problem with the delay function here using the HTML function with
Here's my problem. Suppose I have a table called persons containing, among other things,
I ran into the problem in Java, but I guess it's a question about

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.