如何通过VSPackage扩展中的命令编辑文本? [英] How do I edit text from a command in my VSPackage extension?

查看:55
本文介绍了如何通过VSPackage扩展中的命令编辑文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我单击VSPackage扩展名中的命令时,我正在努力解决如何编辑文本文件中的选定文本.我以前曾问过这个问题,但与之链接的文档对我没有帮助.我再次问这个问题,因为 好像已经回答了该问题,所以以为我可能必须再次添加它才能得到答案.

I'm struggling to work out how you're supposed to edit selected text in a text file when a command in my VSPackage extension is clicked. I've seen this question asked before, but the documents linked to didn't help me. I'm asking this question again, as it looked as though that question had been answered, so thought I might have to add it again to get an answer.

我可以获取IVsTextManager和IVsTextView,甚至可以获取所选的文本,但是无法弄清楚如何获取ITextBuffer等进行任何编辑.有些地方似乎表明我需要制作一个MEF组件来进行编辑,但是我找不到任何文档 关于如何做的事情……虽然那可能只是我在努力寻找合适的东西.如果那是您应该这样做的方式,那么我该如何从命令中调用它呢?

I can get a IVsTextManager and IVsTextView, and even the selected text, but can't work out how to get an ITextBuffer etc to do any editing. Some places seem to indicate that I need to make a MEF component to do the editing, but I can't find any documentation about how to do that... although that could just be me struggling to find the right stuff. If that is how you're supposed to do it, how do I call that from my command?

我正在使用VS 2013,但如果使用起来更简单,则可以使用VS2015.

I'm using VS 2013, but could move to VS2015 if it's easier with that.

推荐答案

ntt monty,

Hi tnt monty,

>> 某些地方似乎表明我需要制作一个MEF组件来进行编辑,但是我找不到有关如何执行此操作的任何文档...
请参考以下MSDN文章,该文章介绍如何通过调用菜单命令在编辑器中向文本视图添加装饰品.希望能为您提供帮助.
https://msdn.microsoft.com/en-us/library/Dd884850 .aspx?f = 255& MSPPError = -2147217396

>>Some places seem to indicate that I need to make a MEF component to do the editing, but I can't find any documentation about how to do that...
Please refer to following MSDN article which introduce how to add an adornment to a text view in the editor by invoking a menu command. Hope it can help you.
https://msdn.microsoft.com/en-us/library/Dd884850.aspx?f=255&MSPPError=-2147217396

由于此问题与Visual Studio Integrate更相关.我将其移至移动服务论坛.这是适当的,更多的专家会为您提供帮助.

Since this issue is more related to Visual Studio Integrate. I move it to the Mobile Service forum. It is appropriate and more experts will assist you.

最好的问候,
威威

Best Regards,
Weiwei


这篇关于如何通过VSPackage扩展中的命令编辑文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆