How to insert code in word and keep the original code style unchanged

Source: Internet
Author: User

How to insert code in word and keep the style unchanged

Sometimes we need to add a piece of code to the word, but after we paste the code into the word document, we will find that all the code looks changed, we can use the following method to ensure that the original style and color of the Code are highlighted.

1. This method is suitable for pasting the code in Visual Studio into a Word document.

A. Select the insert tab in word and click the object

B. Select the OpenDocument text in the pop-up window, and a new word window will pop up. copy and paste the code in Visual Studio here and save the closed window.

C. The following

2. This method is completed using notepad ++, and the effect is very good. Other Editors such as sublime should also have similar functions. I have not tried this method yet.

A. open the written code in Notepad ++ and select plugins → nppexport → copy all formats to clipboard. In this way, you can copy and paste the selected code to the word with the original style.

B.

PublicStatic void main()

{

Console.Writeline("Hello World");

Console.Readkey();

}

If the above effect is directly pasted in the word, the word will show the checked spelling errors in a curve, but if we use the above method to insert the object, then execute the paste operation, and we will see the following effect

Reference:

Http://stackoverflow.com/questions/387453/how-do-you-display-code-snippets-in-ms-word-preserving-format-and-syntax-highlig

How to insert code in word and keep the original code style unchanged

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.