5

I have to replace "something" in file with :something. My editor is kate can anyone suggest a search expression and placeholder for that.

Example

Input

"code"
"name"
"remark"

Output

:code
:name
:remark

3 Answers 3

12

search for "(\w+)", replace with :\1

5
  • 1
    am expecting an explanation for "(\w+)" and \1.what r they
    – Biju CD
    Aug 29, 2009 at 9:15
  • 3
    search tutorial grouping and back references
    – dfa
    Aug 29, 2009 at 9:18
  • @dfa can i use it through perl s/g
    – Biju CD
    Aug 29, 2009 at 9:26
  • A blog post concerning this question/ answer: labs.sasslantis.ee/2012/05/… Jun 15, 2013 at 21:53
  • Works as a charm. Thanks. Stress in the need to use parentheses. I used to replace single-line style comments (cpp) to multiple-line style comments (c ansi). search: (//)(.*) replace: /* \2 */ Very useful.
    – DrBeco
    Aug 11, 2014 at 4:25
3

search: (something)
replace: :\1

0

Why isn't a simple search and replace suitable? pattern: something replace: :something

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.