visual-studio - Visual Studio 2019深色主题: How to copy and paste code to MS Word with default syntax highlighting?

标签 visual-studio

我想从 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. 通过扩展安装生产力电动工具。
  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 是否为 true。

  • 重新启动 Visual Studio。
  • 关于visual-studio - Visual Studio 2019深色主题: How to copy and paste code to MS Word with default syntax highlighting?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57254279/

    相关文章:

    c# - 解决方案中的两个项目使用不同的默认路径

    visual-studio - Visual Studio 和 Temp 文件夹的病毒扫描

    c# - 新空白页 (XAML) 项目 = 控件未显示在 MainPage 上(只有它们的边框显示)

    c# - 为 Windows 窗体自定义控件定义事件

    .net - T4 工具箱 - 当前程序集中的引用类

    visual-studio - Visual Studio 2010 中的 Resharper 快捷键

    visual-studio - 以某种文档/报告格式导出 Visual Studio 测试结果?

    Python pip安装cvxopt错误: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2

    c# - 使用 Xamarin 构建适用于 Windows CE 5.2 的应用程序?

    c++ - 在 Visual Studio 2017 上无法使用 x64 Debug模式进行 opencv3.2 编译