除了宏之外,如何在 TextMate 中执行多次查找和替换?
我有几个正则表达式来查找和替换 TextMate 文档中的文本。我希望能够让它们批量运行。我制作了一个宏并且它有效,但是对宏的任何微小修改都意味着重新录制宏。我似乎无法修改 TextMate 界面中的正则表达式。由于某种原因它是只读的。
我可以把它变成命令吗?有人知道怎么做吗?我尝试阅读有关命令的 TextMate 帮助,但没有太大帮助。看来我需要先了解 shell 脚本或某种类型的知识(我没有)。任何有关该方向的建议都会很棒。
提前致谢。
I have several regular expressions to find and replace text in documents in TextMate. I would like to be able to have them run in a batch. I made a macro and it worked, but any tiny modifications to the macro means re-recording the macro. And I can't seem to modify the regex within the TextMate interface. It's read-only for some reason.
Can I make it into a command? Does anyone know how? I tried to read the TextMate help about commands, but it wasn't much help. It seems I need prior knowledge of shell scripts or some sort (which I have none). Any advise in the direction would be great.
Thanx in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,可以编辑宏。由于这对您来说是最简单的解决方案,因此您可以这样做:
此解决方案对您来说可能是最简单的,因为它不需要您学习脚本语言,并且应该是可以进行微小的更改。然而,另一种非常合理的方法是选择您选择的脚本语言并简单地构建一个命令来运行您的正则表达式。您可以使用 perl、python、ruby、bash 等。一个简单的解决方案应该是 bash 和 sed。 sed 是一个小工具,其唯一目的是处理文本,应该是您的理想选择。 bash 是默认的脚本语言,所以应该没问题。你会以某种方式弄清楚并学到很多东西。尝试一下! :)
First, it's possible to edit macros. Since this is the easiest solution for you, here is how you do it:
This solution may be the easiest for you, because it doesn't require you to learn a scripting language and should be OK for minor changes. However another very reasonable approach is choosing a scripting language of your choice and simply build a command, which runs your regular expressions. You can use perl, python, ruby, bash and so forth. A simple solution should be bash with sed. sed is a small tool, whose only purpose is to process text and should be ideal for you. bash is the default scripting langauge, so should be no problem either. You will figure it out somehow and learn a lot. Give it a try! :)