Visual Studio 2019黑暗主题:如何使用默认语法突出显示功能将代码复制和粘贴到MS Word?

时间:2019-07-29 12:52:22

标签: visual-studio

我想从设置了Dark Theme的Visual Studio 2019社区复制代码部分,并将其粘贴到MS Word,同时保留复制的文本样式,就像在Visual Studio 2017中一样-使用默认代码样式。

带有深色主题的Visual Studio 2017-复制结果(这就是我想要的): enter image description here

带有深色主题的Visual Studio 2019-复制结果(不需要): enter image description here

如何在VS 2019中保留这种行为?

我测试了Copy As Html扩展名,但似乎无法解决问题(或者我遗漏了一些东西)。

1 个答案:

答案 0 :(得分:2)

  1. 从扩展程序安装Productivity Power Tools。
  2. 重新启动Visual Studio。
  3. 转到工具->选项->保护性电动工具-> HTML复制,然后:-

a。将BeforeCodeSnippet更改为:-

<style type='text/css'> .user{color:#006600 !important} .identifier{color: black !important;} .keyword{color: blue !important;} .literal{color: black !important;} .operator{color: black !important;} .string{color: #A31515 !important;} .number{color: black !important;} .Types{color: #2B91AF !important;} .Class{color: #2B91AF !important;} .delegate{color: #2B91AF !important;} .Interface{color: #79B351 !important;} .Interface.name{color: #79B351 !important;} .enum{color: #79B351 !important;} .enum.name{color: #79B351 !important;} .enum.member.name{color: black !important;} .comment{color: #008000 !important;} </style> <pre>

b。将EmitSpanClass更改为 true

c。检查EmitSpanStyle是否为真。

  1. 重新启动Visual Studio。