简体   繁体   中英

Visual Studio 2019 dark theme: How to copy and paste code to MS Word with default syntax highlighting?

I want to copy the code portion from Visual Studio 2019 Community, with Dark Theme set, and paste it to MS Word with preserving the copied text styles as it was done in Visual Studio 2017 - with the default code styling.

Visual Studio 2017 with Dark Theme - copy result (that is what I want): 在此处输入图片说明

Visual Studio 2019 with Dark Theme - copy result (unwanted): 在此处输入图片说明

How to preserve that behaviour in VS 2019?

I tested Copy As Html extension but it didn't seem to solve the issue (or I am missing something).

  1. Install Productivity Power Tools From Extensions.
  2. Restart Visual Studio.
  3. Go to Tools -> Options -> Protectivity Power Tools -> HTML Copy and:-

a. Change BeforeCodeSnippet to:-

<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.Change EmitSpanClass to true .

c. Check if EmitSpanStyle is true.

  1. Restart Visual Studio.

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