Reputation: 155
I have a file and i want to add quotes around every word for example hello becomes "hello" So far i have tried this in emacs:
M-x query-replace-regexp [a-z]+ RET "\1" y
But it just deletes the word and leaves quotes.
Upvotes: 5
Views: 2474
Reputation: 70732
You need to place a capturing group ( )
around your pattern referencing to back reference \1
M-x query-replace-regexp \([a-zA-Z]+\) RET "\1" y
Upvotes: 5
Reputation: 30699
This is what you want:
M-x query-replace-regexp \(\<\w+\>\) RET "\1" y
Upvotes: 6