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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:28:22+00:00 2026-05-24T23:28:22+00:00

I like to use VIM to quickly generate snip of codes from text. Now

  • 0

I like to use VIM to quickly generate snip of codes from text. Now I have case I think I may need to use VIM advanced find & replacement to convert text to a snip of codes. The following text is a simplified example:

value1
value2
...
valueN

I use VIM vertical block to insert prefix string, or use find & replace (:%s/^/public const string /”) to achieve the same result like this:

public const string value1
public const string value2
...
public const string valueN

Now I would like to complete the above text to codes like this:

public const string value1 = "value1";
public const string value2 = "value2";
...
public const string valueN = "valueN";

Note: the value1..valueN are simplified ones, they are actually in various length. Not sure if there is any way to use VIM advanced find & replace to add the suffix string with the last word as 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-24T23:28:23+00:00Added an answer on May 24, 2026 at 11:28 pm

    From your initial list:

     :%s/\(.*\)/public const string \1 = "\1";
    

    Should do it.

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

Sidebar

Related Questions

I would like to have a mapping to quickly quit all buffers, for use
I like to use eclim with vim and auto-completition function, but i have a
I am using slash for searching for stuff within vim. I'd like to use
is it possible to use something like an vim-close/exit-Event to execute some last commands
I use vim under iterm2. I'm using the NERDCommenter plugin, and I'd like to
I use vim. Specifically I am using Janus . I have expandtab set. However,
I use Vim's spell checking to validate texts in Russian. We have letter ё
I normally use VIM to edit my codes and convert them to HTML by
When I use Vim to navigate the source codes such as Linux and Android,
I'd like to use Vim for editing sources and Xcode for all other purposes

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.