Find the answer to your Linux question:
Results 1 to 2 of 2
Hello, I have a small query related to gvim search and replace: How do we replace a PART of search string (not the whole string)? e.g. If we have the ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2010
    Posts
    5

    gvim search and replace related query


    Hello,

    I have a small query related to gvim search and replace: How do we replace a PART of search string (not the whole string)?
    e.g. If we have the following text:
    TMP01_VAR
    TMP02_VAR
    TMP03_VAR
    and so on, and we want to replace it with:
    TMP01_STR
    TMP02_STR
    TMP03_STR
    assuming that VAR exists in many places and we want to replace only those VARs which come with TMP\d{2}.

    We can do something like this in perl:
    =~s/(TMP\d{2})_VAR/($0)_STR
    Is there something similar available in gvim?

    Thanks & Regards.

  2. #2
    Linux Enthusiast
    Join Date
    Jan 2005
    Location
    Saint Paul, MN
    Posts
    668
    Take a look at the substitute command (from back in the em days). Hint it is not in the GUI look for ":s" command as this looks like homework to me.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •