emacs 中宏的查询替换?

发布于 2024-09-07 13:18:42 字数 305 浏览 1 评论 0原文

我经常使用 emacs 中的内置 f3/f4 绑定来记录和重复宏,并发现它是一个非常强大且有用的功能,特别是与搜索结合使用时。然而,我最近注意到,每当我执行查询替换(默认情况下为 MS-5)时,记录我的宏都会停止!有办法防止这种情况吗?我知道查询替换是交互式的,但如果我输入 'y' 3 次进行 3 次替换,我认为宏应该执行相同的操作。

没问题,我想,在录制宏时,我会执行 Cu 3 MS-5,这样它就会精确地进行 3 次替换,因为我知道这对于我正在做的事情来说已经足够好了。但显然查询替换忽略了 Cu!通常宏的使用和铜的使用对我来说是无缝的。有没有办法让它们与查询替换一起使用?

I use the builtin f3/f4 bindings in emacs a lot to record and repeat macros, and find it to be a very powerful and useful feature, especially when combined with search. However, I noticed recently that whenever I do a query-replace (M-S-5 by default) that recording my macro stops! Is there a way to prevent this? I know that query-replace is interactive but if I enter 'y' 3 times to do 3 replaces, I figure the macro should just do the same.

No problem I figure, when recording my macro I'll do C-u 3 M-S-5 so it'll do the replacement exactly 3 times since I know that's good enough for what I'm doing. But apparently query-replace ignores C-u! Usually macro use and C-u use are seamless for me. Is there a way I can make them work with query-replace?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小苏打饼 2024-09-14 13:18:42

在我的 Emacs (23.2) 和没有用户初始化文件 (emacs -q) 的情况下,我发现 query-replace 工作得很好。 测试

这是我输入的

1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5

:我将光标移动到该文本块的顶部

<f3> M-S-5 3 RET tj RET y y y q <f4>

,这给我留下了:

1 2 tj 4 5
1 2 tj 4 5
1 2 tj 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5

再次按下 给我留下了:

1 2 tj 4 5
1 2 tj 4 5
1 2 tj 4 5
1 2 3 4 5
1 2 tj 4 5
1 2 tj 4 5
1 2 tj 4 5
1 2 3 4 5

按预期工作。我建议尝试使用 emacs -q 以确保您没有任何影响行为的自定义。

With my Emacs (23.2) and no user init file (emacs -q), I find that query-replace works just fine. This is my test

I typed in:

1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5

I moved the cursor to the top of that text block

<f3> M-S-5 3 RET tj RET y y y q <f4>

which left me with:

1 2 tj 4 5
1 2 tj 4 5
1 2 tj 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5

Pressing <f4> again left me with:

1 2 tj 4 5
1 2 tj 4 5
1 2 tj 4 5
1 2 3 4 5
1 2 tj 4 5
1 2 tj 4 5
1 2 tj 4 5
1 2 3 4 5

Works as expected. I'd recommend trying with emacs -q to ensure you don't have any customizations that affect the behavior.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文