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.
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.
This is what you want:
M-x query-replace-regexp \(\<\w+\>\) RET "\1" y
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
ok i got it, instead od the \1 I need to put \& in the replace part
© 2022 - 2024 — McMap. All rights reserved.