代码美化的两种方法

一、使用 carbon 生成图片:

网址:https://carbon.now.sh

你可以自行调整代码显示效果,或者直接 Import 我的配置文件,在设置里找一下 Import config 选项即可。

效果图如下:

配置文件内容如下,文件名为 carbon-config.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
{
"paddingVertical": "0px",
"paddingHorizontal": "0px",
"backgroundImage": null,
"backgroundImageSelection": null,
"backgroundMode": "color",
"backgroundColor": "rgba(255,255,255,1)",
"dropShadow": false,
"dropShadowOffsetY": "0px",
"dropShadowBlurRadius": "0px",
"theme": "vscode",
"windowTheme": "sharp",
"language": "python",
"fontFamily": "JetBrains Mono",
"fontSize": "16px",
"lineHeight": "125%",
"windowControls": false,
"widthAdjustment": true,
"lineNumbers": true,
"firstLineNumber": 1,
"exportSize": "4x",
"watermark": false,
"squaredImage": false,
"hiddenCharacters": false,
"name": ""
}

二、使用 VS Code 生成格式化代码:

在 VS Code 中打开你的代码文件,然后安装对应编程语言的插件,插件生效后,复制你的代码,粘贴到 Word 中,粘贴选项选择 保留源格式 即可。

因为 VS Code 和 Word 都是微软公司的,所以 VS Code 中的代码复制到 Word 后,会自动进行排版,无需自行调整。

效果图如下:


代码美化的两种方法
https://roachlin.github.io/2021-01-11-code-beautify/
作者
RoachLin
发布于
2021年1月11日
许可协议