首页 > 其他分享 >How do you display code snippets in MS Word preserving format and syntax highlighting?

How do you display code snippets in MS Word preserving format and syntax highlighting?

时间:2023-06-06 13:44:06浏览次数:45  
标签:do code word MS Word Copy

How do you display code snippets in MS Word preserving format and syntax highlighting?

回答1

Here is the best way, for me, to add code inside word:

  1. Go to Insert tab, Text section, click Object button (it's on the right)
  2. Choose OpenDocument Text which will open a new embedded word document
  3. Copy and paste your code from Visual Studio / Eclipse inside this embedded word page
  4. Save and close

Advantages

The result looks very nice. Here are the advantages of this method:

  • The code keeps its original layout and colors
  • The code is separated from the rest of the document, as if it was a picture or a chart
  • Spelling errors won't be highlighted in the code (this is cool !)

And it takes only few seconds.

 

For Word 2011 on OSX use: Insert -> Object...Microsoft Word Document – s_t_e_v_e Apr 7, 2014 at 17:19

 

 

回答2

Download and install Notepad++ and do the following:

  1. Paste your code in the window;

  2. Select the programming language from the language menu;

  3. Select the text to copy;

  4. Right click and select Plugin commands -> Copy Text with Syntax Highlighting;

  5. Paste it into MS Word and you are good to go!

Update 29/06/2013:

Notepad++ has a plugin called "NppExport" (comes pre-installed) that allows you to copy to RTF, HTML and ALL. It permits dozens of languages, whereas the aforementioned IDEs are limited to a handful each (without other plug-ins).

I use Copy all formats to clipboard and "paste as HTML" in MS word.

 

Thanks for this hint. Plugins -> NppExport -> Copy RTF to Clipboard also works. – Andrew Huey May 16, 2011 at 17:32    

 

标签:do,code,word,MS,Word,Copy
From: https://www.cnblogs.com/chucklu/p/17460324.html

相关文章

  • 关联规则二项集hadoop实现
    近期看mahout的关联规则源码,颇为头痛,本来打算写一个系列分析关联规则的源码的,但是后面看到有点乱了,可能是稍微有点复杂吧,所以就打算先实现最简单的二项集关联规则。算法的思想还是参考上次的图片:这里实现分为五个步骤:针对原始输入计算每个项目出现的次数;按出现次数从大到小(排除出现......
  • Unexpected character '"' (code 34) in DOCTYPE declaration; expected a space betw
    1)错误信息Causedby:javax.xml.ws.WebServiceException:org.apache.cxf.service.factory.ServiceConstructionException:Failedtocreateservice.atorg.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:149)atorg.apache.cxf.jaxws.spi.Provider......
  • 云原生之使用Docker部署Booksonic有声读物平台
    (云原生之使用Docker部署Booksonic有声读物平台)一、Booksonic介绍Booksonic是一个可以随时随地访问您拥有的有声读物的平台。二、检查docker状态[root@node~]#systemctlstatusdocker●docker.service-DockerApplicationContainerEngineLoaded:loaded(/usr/......
  • org.codehaus.plexus.archiver.jar.Manifest.write(java.io.PrintWriter)
    DescriptionResourcePathLocationTypeorg.codehaus.plexus.archiver.jar.Manifest.write(java.io.PrintWriter)pom.xml/gs-rest-serviceline1MavenConfigurationProblem在学习springboot实例时,发现了这个Maven配置错误,但是不影响springboot运行。问题......
  • CentOS7 通过 yum 安装 Docker
    从Docker官网上也能够找到CentOS7安装Docker的文档,但是文档比较简略,为了能够在安装过程中少走一些弯路,还是很有必要写一下Docker安装的博客总结,方便后续提高工作效率。CentOS7安装Docker的官网文档地址为:https://docs.docker.com/engine/install/centos/Docker主要......
  • 数字取证-计算机取证篇-Windows计算机取证
    Windows计算机取证Windows现场取证流程去现场勘察之前要准备好案件同步,物证,取证工具,现场取证的U盘硬盘,录像机,物证袋,封条等等。收集相关的物证比如电脑,手机,外设(光盘,硬盘,U盘,数据连接线),设备等。如果计算机在开机状态要准备好在线取证,对于在计算机上正在运行的重要数据,重要程序......
  • VsCode配置Wdk7600开发环境 以及 "自动编译" 和 sources文件简单介绍..
    目录VsCode配置Wdk7600开发环境以及"自动编译"和sources文件简单介绍..一丶简介1.2软件安装1.3开发环境配置步骤1.4集成终端编译1.4.1集成任务1.4.2设置为全局任务.二丶Sources文件编程2.1INCLUDES字段2.2i386_SOURCES32位驱动使用内联汇编2.3AMD64_SOURCES使用......
  • Windows环境FFmpeg下载、环境变量配置
    FFmpeg官网下载地址第一步:点击Download下载按钮第二步:选择适合当前的运行环境,选择windows第一个地址Windowsbuildsfromgyan.dev第三步:选择releasebuilds中合适的版本第四步:环境变量配置,我安装的目录是:E:\ProgramFiles\ffmpeg-6.0-essentials_build点击ffmpeg安装......
  • 【Windows】Zookeeper伪集群安装
    下载zookeeper下载地址:http://archive.apache.org/dist/zookeeper/解压后,目录重命名为zookeeper1,进入conf目录,把zoo_sample.cfg复制一份,重命名为zoo.cfg。编辑zoo.cfg配置数据目录和日志目录先在zookeeper1目录下,新建目录data、logs#------------日志目录------------#......
  • Asp.Net Core 程序部署到Linux(centos)生产环境(二):docker部署
    运行环境照例,先亮环境;软件的话我这里假设你已经批准好了.netcore运行环境,未配置可以看我的这篇[linux(centos)搭建.netcore运行环境]腾讯云centos:7.2cpu:1核2G内存1M带宽docker:18.06.1-ce安装docker安装其实很简单,就不重复说了,请查看纯洁大神这篇文章准备你的.netcoreweb程......