扩展 Visual Studio 2010 - 使用键盘快捷键替换编辑器中的文本
我想为 Visual Studio 2010 编辑器编写一个扩展,用于替换/编辑所选文本。我已经想出了如何通过选择“其他项目类型 - 可扩展性 - 添加”来以“旧方式”执行此操作,但据我所知,这几乎是遗留问题,并且包括大量 COM 互操作和混乱,例如那。
我可以在网上找到的新型可扩展性项目(“新项目 - C# - 可扩展性”)的示例仅操纵颜色等内容,并在字母周围制作方框和类似的无用内容。
这可以使用 MEF 和 VSIX 来完成吗?还是我必须退回到旧方法?
我想要做的:
- 创建一个添加菜单项(可能还有工具栏按钮)的扩展
- 当用户单击按钮/菜单项(或分配的键盘快捷键)时,当前选定的文本将根据加载项进行更改行为。
我已经成功地使用旧版加载项做到了这一点,但当新的 MEF 内容出现时,使用如此多的互操作感觉“错误”。非常感谢任何示例、代码示例、教程等!
I want to write an extension for the Visual Studio 2010 editor, that replaces/edits the selected text. I've figured out how to do this the "old way" by selecting a "Other Project Types - Extensibility - Add In", but as far as I know, this is pretty much legacy, and includes alot of COM Interop and mess like that.
The samples I can find online for the new type of extensibility-project ("New Project - C# - Extensibility") only manipulates stuff like colors and makes boxes around letters and useless stuff like that.
Can this be done with MEF and VSIX, or do I have to fall back to the legacy-method?
What I want to do:
- Create an extension that adds a menu item (and maybe a toolbar button)
- When the user clicks the button/menu item (or a assigned keyboard shortcut), the current selected text is changed according to the add-ins behavior.
I've managed to do this with legacy add-in, but it feels "wrong" working with so much interop, when the new MEF stuff is out there. Any samples, code examples, tutorials etc. is greatly appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
传统方法是使用 Visual Studio 集成包服务,但现在您可以利用 的强大功能MEF 框架。请查看此处:
Legacy approach is to use Visual Studio Integration Package services, but now you can leverage power of the MEF Framework. Take a look here: