开发者

Extending Visual Studio 2010 - Replace text in editor with keyboard shortcut

开发者 https://www.devze.com 2023-04-07 08:34 出处:网络
I want to write an extension for the Visual Studio 2010 editor, that replaces/edits开发者_Python百科 the selected text. I\'ve figured out how to do this the \"old way\" by selecting a \"Other Project

I want to write an extension for the Visual Studio 2010 editor, that replaces/edits开发者_Python百科 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!


Legacy approach is to use Visual Studio Integration Package services, but now you can leverage power of the MEF Framework. Take a look here:

  • Extending the Editor
  • Managed Extensibility Framework in the Editor
  • Walkthrough: Highlighting Text
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号