简体   繁体   中英

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

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!

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM