先看示例

找了篇博客寫的賊詳細 https://blog.csdn.net/xujingyiss/article/details/118992763
只要設置這二個

let content = ""; 可以寫你需要的樣式
配置如下
const cmOptions = { mode: 'text/x-mysql', // //語言模式 theme: 'neo', // 主題 lineNumbers: false, // 顯示行號 smartIndent: true, //智能縮進 indentUnit: 4, // 智能縮進單元長度為 4 個空格 foldGutter: true, // 代碼折疊 styleActiveLine: true, // 顯示選中行的樣式 matchBrackets: true, //每當光標位於匹配的方括號旁邊時,都會使其高亮顯示 autofocus: true, showCursorWhenSelecting: true, autocorrect: true, spellcheck: true, specialChars: /[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g, specialCharPlaceholder: function (ch) { let token = document.createElement("span"); let content = ""; token.className = "cm-invalidchar"; if (typeof content == "string") { token.appendChild(document.createTextNode(content)); } token.title = "\\u" + ch.charCodeAt(0).toString(16); token.setAttribute("aria-label", token.title); return token }, // 代碼折疊 gutters: [ "CodeMirror-lint-markers", "CodeMirror-linenumbers", "CodeMirror-foldgutter" ], foldGutter: true, // 啟用行槽中的代碼折疊 }
可以看下上面的博客里面或許有你們需要的
改完之后就是下面這樣

