我正在尝试为匹配的文本设置自定义语法突出显示(前景色和背景色)。
我正在使用CSV文件,示例行:
“ n”,“”,“”,“ 2018-12-25 06:25:36 PM”
我想将“ n”突出显示为深绿色背景和浅绿色前景。也许也有边界?
答案 0 :(得分:0)
您可以使用highlight extension:
在您的设置中:
"highlight.regexes": {
"(\\\")([^\\\"]*?)(\\\",)(.*)$": {
"regexFlags": "m",
"filterFileRegex" : ".*\\.csv",
"decorations" : [
{}, // first capture group, " do nothing
{ // the second capture group that you are interested in
"color": "lightgreen",
"fontWeight": "bold",
"padding": "3px", // only pads top and bottom unfortunately
"backgroundColor": "darkgreen",
"border": "1px solid white",
"borderRadius": "3px"
},
{} // third capture group, ", do nothing
]
}
}
这会将突出显示过滤器仅应用于.csv文件,如果文件的扩展名不同,则可以修改该条目。
正则表达式采用以下模式:
"n","","","2018-12-25 06:25:36PM"
并且您想为第一对括号中的任何内容着色,所以可能是:
"nabcd...more","","","2018-12-25 06:25:36PM"