emacs中是否在区域中的每个行上都应用了一条命令? [英] Is there an apply-command-to-each-line-in-region in emacs?

查看:48
本文介绍了emacs中是否在区域中的每个行上都应用了一条命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一堆链接保存在orgmode文件中,例如...

I have a bunch of links saved in an orgmode file, say...

http://www.stackoverflow.com
http://www.google.com
http://www.github.com

我可以通过将光标放在链接上并执行 C-c C-o 来打开每个链接,它方便地弹出我的默认浏览器并在选项卡中打开该链接.

I can open each one by having the cursor on the link and doing C-c C-o, and it conveniently pops up my default browser and opens that link in a tab.

现在假设我喜欢这些链接中的20个.是否有一种简便的方法可以将这样的函数应用于选定区域中的每一行,而无需记录显式宏?

Now suppose I have like 20 of these links. Is there a convenient way to apply a function like this to each line within a selected region, without recording an explicit macro?

我想它看起来像...

I'd imagine it looking something like...

Select region
M-x foreach-in-region
Keystrokes to apply to each line: C-c C-o

这仅适用于已定义的功能.我想如果没有的话,就像...

And this is just for functions already defined. I imagine the way without would be something like...

with cursor on first line of link
F3 # to start record macro
C-c C-o 
down arrow
F4
Select region (omitting the first line, since that's now already opened in my browser)
C-x C-k r

这存在吗?如果没有,我该怎么想呢?

Does this exist? If not, how would I lisp this?

推荐答案

您应该记录宏一行,然后使用 apply-macro-to-region-lines 对所有行执行该宏在该地区. C-x C-k r

You should record the macro for one line, then use apply-macro-to-region-lines to execute it for all lines in region. C-x C-k r

或者,您可以使用多个光标在每一行上创建一个光标,并使用 C-c C-o 打开所有光标.如果有机会,多个光标将随着时间的推移改变您的使用方式.

Alternatively, you can use multiple-cursors to create a cursor on each line and C-c C-o to open all. multiple-cursors will transform your usage patterns over time for the better if you give it a chance.

这篇关于emacs中是否在区域中的每个行上都应用了一条命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆