当我在 Visual Studio 2005 中保存文件时是否可以运行宏?
当我在 Visual Studio 2005 中保存文件时,我希望还运行一个更新版权的宏(通过正则表达式搜索和替换)。
我对正则表达式并不陌生,但我对 VB/VBA 和 Visual Studio 宏不熟悉,所以我具体需要帮助的是:
让宏在保存时运行,最好是在按 CTRL-S 之后运行,但是在它实际写入文件之前,以便实际保存搜索和替换的结果,而不必保存两次
从 VB/VBA 宏内部调用正则表达式的搜索和替换
When I save a file in Visual Studio 2005, I'd like to have a macro also run that updates a copyright (through a regular expression search and replace).
I'm not new to regular expressions, but I am new to VB/VBA and Visual Studio macros, so what I need help with specifically is:
getting a macro to run upon save, preferably after I press CTRL-S but before it actually writes the file so that the results of the search and replace are actually saved without having to save twice
calling search and replace for a regular expression from inside the VB/VBA macro
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以录制、重命名和分配宏。这就是我所做的。
因此,您可以录制几乎您想要的内容。然后对其进行调整,并将其分配给组合键。一定要先尝试你的正则表达式,并注意如果你的解决方案中的任何内容是只读的,将会有一个对话框打断你。
You can record, rename, and assign a macro. Here's what I did.
System.Text.RegularExpressions
.So the idea is you can record something that is almost what you want. Then tweak it, and assign it to a key combination. Definitely try your regex first and note that there will be a dialog interrupting you if anything in your solution is read-only.