Emacs在每个单词周围添加引号

arb*_*ast 4 regex emacs expression replace elisp

我有一个文件,我想在每个单词周围加上引号,例如hello变成“ hello” 到目前为止,我已经在emacs中尝试过此操作:

M-x query-replace-regexp [a-z]+ RET "\1" y
Run Code Online (Sandbox Code Playgroud)

但是它只是删除单词并留下引号。

Dre*_*rew 5

这就是你想要的:

M-x query-replace-regexp \(\<\w+\>\) RET "\1" y
Run Code Online (Sandbox Code Playgroud)


hwn*_*wnd 5

您需要( )在您的模式周围放置一个捕获组,以引用反向引用 \1

M-x query-replace-regexp \([a-zA-Z]+\) RET "\1" y
Run Code Online (Sandbox Code Playgroud)


arb*_*ast 3

好的,我明白了,而不是 \1 我需要将 \& 放入替换部分