VScode 暗黑风格:

代码内容VS Code 识别类型颜色表现
intvoidunsigned基础类型 / 关键字橙红色、蓝色等
whileif控制流关键字紫色、粉色等
uint16_tuint32_t类型名 / typedef青绿色或浅蓝
JScope_Init()函数调用紫色/蓝色
PID_Vol_Loop.Ref结构体变量 + 成员可分别高亮
system_1ms_count普通变量浅蓝或白色
// 注释注释绿色

在这里插入图片描述
在这里插入图片描述

Keil5 中的自定义风格:

在这里插入图片描述

在这里插入图片描述


Edit → Configuration → Colors & Fonts

在这里插入图片描述

左侧 Window 每个选项是什么意思

Window 项目作用建议
All Editors所有编辑窗口的通用设置,比如当前行、选中颜色、右边距线必须设置
Asm Editor files汇编文件 .s.asm 的颜色写汇编才需要
Build Output Window编译输出窗口建议也改暗色
C/C++ Editor files.c.h 文件代码高亮最重要
Debug Command Window调试命令窗口可改暗色
Disassembly Window反汇编窗口调试时会用
Editor Text files普通文本文件 .txt可改暗色
Logic AnalyzerKeil 逻辑分析器窗口可不改
Memory Window调试时查看内存的窗口可改暗色
UART #1/#2/#3 WindowKeil 仿真串口窗口可改暗色

C/C++ Editor files右侧 Element 选项是什么意思

在这里插入图片描述

项目含义举例
Text普通文本,默认代码颜色普通变量、空白区域基础颜色
Number数字常量1230x553.14
Operator, Block, Brackets运算符、代码块符号、括号+ - * / = { } ( ) [ ]
Block Comment块注释/* 这里是注释 */
Line Comment行注释// 这里是注释
KeywordC 语言关键字ifelsewhilereturnstatic
String字符串"hello""UART Init"
Identifier标识符,一般是变量名、函数名mainPWM_Initadc_value
Preprocessor预处理指令#include#define#if
Character字符常量'A''\n'
Matching Braces匹配成功的括号光标放在 { 时,对应的 } 高亮
Mismatched Braces不匹配的括号少了一个 } 或括号配对错误
User Keyword / Label用户自定义关键字或标签汇编标签、用户定义的高亮词
Incomplete String未完成字符串"abc 少了右引号
Inactive Text非激活代码条件编译中被禁用的代码,例如 #if 0 ... #endif

按 VS Code Dark+ 风格设置

1. 普通代码和背景

ElementForeground 色号Foreground RGBBackground 色号Background RGB
Text#D4D4D4212, 212, 212#1E1E1E30, 30, 30
Identifier#9CDCFE156, 220, 254#1E1E1E30, 30, 30
Operator, Block, Brackets#D4D4D4212, 212, 212#1E1E1E30, 30, 30

2. 关键字、字符串、数字

ElementForeground 色号Foreground RGBBackground 色号Background RGB
Keyword#569CD6255, 168, 64#1E1E1E30, 30, 30
String#CE9178206, 145, 120#1E1E1E30, 30, 30
Character#CE9178206, 145, 120#1E1E1E30, 30, 30
Number#B5CEA8181, 206, 168#1E1E1E30, 30, 30

3. 注释和宏定义

ElementForeground 色号Foreground RGBBackground 色号Background RGB
Line Comment#6A9955106, 153, 85#1E1E1E30, 30, 30
Block Comment#6A9955106, 153, 85#1E1E1E30, 30, 30
Preprocessor#C586C0197, 134, 192#1E1E1E30, 30, 30

4. 括号匹配和错误提示

这几个可以不要完全黑色背景,因为它们本来就是提示用的。

ElementForeground 色号Foreground RGBBackground 色号Background RGB
Matching Braces#FFFFFF255, 255, 255#264F7838, 79, 120
Mismatched Braces#FFFFFF255, 255, 255#F44747244, 71, 71
Incomplete String#F44747244, 71, 71#1E1E1E30, 30, 30
Inactive Text#6A6A6A106, 106, 106#1E1E1E30, 30, 30

在这里插入图片描述


在这里插入图片描述

Element作用Foreground 前景色RGBBackground 背景色RGB
Caret Line当前光标所在行#D4D4D4212,212,212#2A2D2E42,45,46
Text Selection鼠标选中的文本#FFFFFF255,255,255#264F7838,79,120
Right Margin右侧代码长度参考线#3C3C3C60,60,60#1E1E1E30,30,30

字体建议

Font:Consolas
Size:11 或 12
Style:Normal

总结

VS Code 可以把关键字、数据类型、函数名、变量名、结构体成员等分得很细;Keil5 的编辑器做不到这么细。

Keil5 的语法高亮比较老,它更多是“按大类染色”,不是像 VS Code 那样做“语义级别高亮”。


配置迁移

Keil5 没有像 Altium Designer 那种完整的“设置导入/导出”按钮。它主要靠复制配置文件迁移。

暗黑主题、字体、颜色、当前行颜色、选中颜色这类设置,核心在 Keil 安装目录下的 UV4 文件夹里,最关键的是:

global.prop
文件建议是否备份作用
global.prop必须颜色、字体、编辑器外观、当前行、选中颜色等
global.prop.def可选默认配置模板,通常不用改
arm.prop建议可能和 ARM/C/C++ 编辑器相关用户关键字等有关
TOOLS.INI可选工具链路径、编译器路径等
UV4.ini可选µVision 一些全局状态/工具设置,版本间可能有差异

在这里插入图片描述

global.prop

# properties for all file types
indent.automatic=1
virtual.space=0
view.whitespace=0
view.endofline=0
code.page=936
caretline.visible=1
highlight.matchingbraces=1
print.syntax.coloring=1
use.tab.color=1
create.backup.files=0
auto.load.ext.modfiles=0
save.prj.before.dbg=0
save.files.before.dbg=0
function.scanner.project=1
function.scanner.files=1
function.scanner.modules=1

# properties for c/cpp files
syntax.colouring.cpp=1
use.tab.cpp=0
tabsize.cpp=2
line.margin.visible.cpp=1
fold.cpp=1
monospaced.font.cpp=1

# properties for asm files
syntax.colouring.asm=1
use.tab.asm=0
tabsize.asm=4
line.margin.visible.asm=1
monospaced.font.asm=1

# properties for other files
use.tabs=0
tabsize=4
line.margin.visible.txt=0
monospaced.font.txt=1

# setting for code completion and syntax check
cc.autolist=1
cc.highlightsyntax=1
cc.showparameters=1
cc.triggerlist=1
cc.triggernumchars=3
cc.enter.as.fillup=0
cc.usealpha4inactcode=0
cc.alphavalue=50

# autosave for editor files
autosave=0
autosave.interval=5

# vertical edge at right margin
edge.mode=0
edge.column=80


# Specification for text selection and caret line
selection.fore=#D4D4D4
selection.back=#264F78
caret.fore=#D4D4D4
caret.back=#2A2D2E

# Color for vertical edge
edge.colour=#3C3C3C

# C/C++ Editor files
template.cpp="#define","#define |";"#if","#if |\r\n\r\n#endif";\\
    "#include","#include ";"Header","// Header:\r\n// File Name: |\r\n// Author:\r\n// Date:\r\n";\\
    "continue","continue;";"do","do\r\n{\r\n\t// TODO: enter the block content here\r\n\t\r\n\t|\r\n} while ();\r\n";\\
    "enum","enum |\r\n{\r\n\t\r\n};\r\n";"for","for(|;;)\r\n{\r\n}";\\
    "fpointer_type","typedef int (* |F)();\r\n";"function","void function(|)\r\n{\r\n\r\n}\r\n";\\
    "if","if (|)";"ifelse","if (|)\r\n{\r\n}\r\nelse\r\n{\r\n}";\\
    "struct","struct | \r\n{\r\n\r\n};\r\n";"switch","switch (|)\r\n{\r\n\tcase:\r\n\t\tbreak;\r\n\tcase:\r\n\t\tbreak;\r\n\tdefault:\r\n\t\tbreak;\r\n}";\\
    "void","void | ();\r\n";"while","while (|)\r\n{\r\n}";\\
    
font.monospace.cpp=Consolas
font.acpmonofontname.cpp=Consolas
font.acppropfontname.cpp=Consolas
style.cpp.32=font:Consolas,size:12,fore:#D4D4D4,back:#1E1E1E
style.cpp.4=font:Consolas,size:12,fore:#B5CEA8,back:#1E1E1E
style.cpp.10=font:Consolas,size:12,fore:#D4D4D4,back:#1E1E1E
style.cpp.1=font:Consolas,size:12,fore:#6A9955,back:#1E1E1E
style.cpp.2=font:Consolas,size:12,fore:#6A9955,back:#1E1E1E
style.cpp.5=font:Consolas,size:12,fore:#FF8040,back:#1E1E1E
style.cpp.6=font:Consolas,size:12,fore:#7F007F,back:#1E1E1E
style.cpp.11=font:Consolas,size:12,fore:#9CDCFE,back:#1E1E1E
style.cpp.9=font:Consolas,size:12,fore:#C586C0,back:#1E1E1E
style.cpp.7=font:Consolas,size:12,fore:#CE9178,back:#1E1E1E
style.cpp.34=font:Consolas,size:12,fore:#FFFFFF,back:#264F78
style.cpp.35=font:Consolas,size:12,fore:#FFFFFF,back:#F44747
style.cpp.16=font:Consolas,size:12,fore:#4EC9B0,back:#1E1E1E
style.cpp.12=font:Consolas,size:12,fore:#F44747,back:#1E1E1E
style.cpp.86=font:Consolas,size:12,fore:#6A6A6A,back:#1E1E1E


# Asm Editor files
font.monospace.asm=Courier New
style.asm.32=font:Courier New,size:10,fore:#000000,back:#FFFFFF
style.asm.1=font:Courier New,size:10,fore:#616161,back:#FFFFFF
style.asm.2=font:Courier New,size:10,fore:#FF0000,back:#FFFFFF
style.asm.3=font:Courier New,size:10,fore:#7F007F,back:#FFFFFF
style.asm.4=font:Courier New,size:10,fore:#000000,back:#FFFFFF
style.asm.5=font:Courier New,size:10,fore:#000000,back:#FFFFFF
style.asm.6=font:Courier New,size:10,fore:#0000FF,back:#FFFFFF
style.asm.7=font:Courier New,size:10,fore:#0000FF,back:#FFFFFF
style.asm.9=font:Courier New,size:10,fore:#0000FF,back:#FFFFFF
style.asm.10=font:Courier New,size:10,fore:#0000FF,back:#FFFFFF
style.asm.11=font:Courier New,size:10,fore:#007F00,back:#FFFFFF
style.asm.12=font:Courier New,size:10,fore:#7F007F,back:#FFFFFF
style.asm.8=font:Courier New,size:10,fore:#46AA03,back:#FFFFFF


# Editor Text files
font.monospace.txt=Consolas
style.txt.32=font:Verdana,size:10,fore:#000000,back:#FFFFFF

arm.prop

# C/C++ Editor files
# User keywords
keywords6.$(file.patterns.cpp)=



# Asm Editor files
# User keywords
keywords6.$(file.patterns.asm)=



# Editor Text files
# User keywords
keywords6.$(file.patterns.txt)=

更多推荐