怎么自定義設(shè)置VSCode編輯器的主題和代碼顏色?下面本篇文章就來(lái)給大家介紹一下修改主題和代碼顏色的方法,希望對(duì)大家有所幫助!
在VS Code 的左下角,點(diǎn)擊設(shè)置。
打開(kāi)設(shè)置后,在搜索欄搜索關(guān)鍵字:主題。
搜索結(jié)果顯示有許多個(gè)在setting.json中編輯,任意點(diǎn)開(kāi)一個(gè),即可編輯代碼的顏色。【推薦學(xué)習(xí):《vscode入門(mén)教程》】
在文件setting.json的代碼后面,插入相應(yīng)的代碼,然后保存。
代碼如下:
// 自定義的顏色 "editor.tokenColorCustomizations": { "comments": "#55aa7f", // 注釋 "keywords": "#ff55ff", // 關(guān)鍵字 "variables": "#a792e2", // 變量名 "strings": "#00ff7f", // 字符串 "functions": "#ffff00", // 內(nèi)置函數(shù)名 "numbers": "#00eeff", // 數(shù)字 "types": "#55bbff", //類定義顏色 },
你會(huì)發(fā)現(xiàn)編輯器里的代碼顏色隨之改變了。
發(fā)現(xiàn)引號(hào)的顏色,還是不太喜歡,于是又找了許久資料,繼續(xù)折騰。
//文本匹配規(guī)則后面的代碼,會(huì)覆蓋前面的顏色設(shè)置代碼。
// 自定義的顏色 "editor.tokenColorCustomizations": { "comments": "#55aa7f", // 注釋 "keywords": "#ff55ff", // 關(guān)鍵字 "variables": "#5eccf8", // 變量名 函數(shù)的參數(shù)名 "strings": "#00ff7f", // 字符串 "functions": "#ffbb00", // 自定義及內(nèi)置的函數(shù)名稱 如:print "numbers": "#00eeff", // 數(shù)字 "types": "#55bbff", //類定義顏色 //文本匹配規(guī)則 "textMateRules": [ //entity.name.function", //直接調(diào)用的函數(shù) //entity.name.type", //typedef定義的變量 //keyword.control", //if switch break return //keyword.operator.assignment", // =等號(hào)/賦值號(hào) |= &= //"keyword.operator.logical", //邏輯符號(hào) && || ! //"constant.character.escape", //"rn" //constant.other.placeholder", //"%s %c" //punctuation.definition.comment", // // /*注釋開(kāi)頭 //constant.numeric", //數(shù)字:50 10 0x20的20部分 //keyword.operator.word //and or not //"scope":"meta", //括號(hào) 函數(shù)聲明的括號(hào) 調(diào)用的括號(hào)... //punctuation.separator", //冒號(hào) 逗號(hào) //punctuation.terminator", //分號(hào) //storage.modifier", //static const //string.quoted.single", //單引號(hào)字符串 //string.quoted.double", //雙引號(hào)字符串 //string.quoted.triple", //三引號(hào)字符串 //"storage.type", //void int char //"punctuation.definition.string.begin", //左雙引號(hào) //"punctuation.definition.string.end", //右雙引號(hào) //########################################################################## //系統(tǒng)內(nèi)置的函數(shù)名稱的顏色 如:print len { "scope": "support.function", "settings": { "foreground": "#ffbb00", } }, //類的名稱顏色 如class abc() 中的abc { "scope": "entity.name.type", //函數(shù)和類的名稱顏色 "settings": { "foreground": "#14fff3", } }, //類和函數(shù)的定義單詞顏色 def class { "scope": "storage.type", //void int char "settings": { "foreground": "#ff00c8", } }, //不知道是什么 { "scope": "storage.modifier", //static const "settings": { "foreground": "#ffe600de", } }, //運(yùn)算符號(hào),如 +-*/= { "scope": "keyword.operator", //=等號(hào)/賦值號(hào) |= &= "settings": { "foreground": "#ff55ff", } }, // 系統(tǒng)的控制關(guān)鍵詞:如 if pass return f { "scope": "keyword.control", //if switch break return "settings": { "foreground": "#ff00c8", "fontStyle": "" } }, //邏輯符號(hào):如 and or { "scope": "keyword.operator.logical", //邏輯符號(hào) && || ! "settings": { "foreground": "#ff00c8", "fontStyle": "" } }, //換行符、轉(zhuǎn)義符等如 :r n { "scope": "constant.character.escape", //"rn" "settings": { "foreground": "#ee5050", "fontStyle": "" } }, //不知道是什么 { "scope": "variable.other", //結(jié)構(gòu)體對(duì)象和成員等 "settings": { //VSCode使用C的顏色限制,這一點(diǎn)比較坑 "foreground": "#4f1eff", //比如Public.Delay(),顏色是一起變得 "fontStyle": "" //不能單獨(dú)設(shè)置Public和Delay的顯示顏色 } //可能因?yàn)閂S Code主要用于前端,對(duì)C的支持不夠完善 }, //函數(shù)的參數(shù)名稱 { "scope": "variable.parameter", //函數(shù)參數(shù)-定義階段 "settings": { "foreground": "#5eccf8", "fontStyle": "" } }, { "scope": "entity.name.section", //函數(shù)參數(shù)-調(diào)用階段 "settings": { "foreground": "#ff0000", "fontStyle": "" } }, // 左單雙引號(hào) { "scope": "punctuation.definition.string.begin", "settings": { "foreground": "#00ff7f", "fontStyle": "bold" } }, //右單雙引號(hào) { "scope": "punctuation.definition.string.end", "settings": { "foreground": "#00ff7f", "fontStyle": "bold" //加粗 } }, { "scope": [ "constant.other.symbol", ], "settings": { "foreground": "#ff0000" } } ] },
現(xiàn)在變成了這樣子:
成功修改了引號(hào)的顏色。但是True、None等系統(tǒng)保留字還是不知道怎么修改。
先這樣吧,基本可用了!
對(duì)我而言,顏值第一,賞心悅目的重要性,永遠(yuǎn)靠前!