xiaohan2012
xiaohan2012

Reputation: 10332

Replace once part of the query in Emacs

I have such requirement for search&replace in Emacs:

I have a bunch of

'A', 'High'
'B', 'High'
'C', 'High'
'D', 'High'

And the list goes on.

I want to replace them to be:

A = 'High'
B = 'High'
C = 'High'
D = 'High'

Can I query for the pattern, say '#', 'High' and replace it with #= 'High?

Upvotes: 1

Views: 52

Answers (1)

abo-abo
abo-abo

Reputation: 20342

Move point to beginning of buffer. M-x query-replace-regexp. Enter '\([^']+\)', '\([^']+\)' as regexp and \1 = '\2' as replacement. Press ! to replace all at once, or keep pressing y/n for each match.

Upvotes: 2

Related Questions