現在工作環境換到MAC上,打算改用 sublime 來做記錄
這邊紀錄一下,怎麼新增 language 和 syntax rule
1. 參考網址
首先用 package control 安裝 PackageDev
安裝好後,創建新的 syntax definition
創好的檔案長得會像這樣
name :
The name that Sublime Text will display in the syntax definition drop-down list.
Use a short, descriptive name. Typically, you will use the name of the programming
language you are creating the syntax definition for.
scopeName :
The topmost scope for this syntax definition. It takes the form source.<lang_name> or
text.<lang_name>. For programming languages, use source. For markup and everything
else, use text.
fileTypes :
This is a list of file extensions (without the leading dot). When opening files of
these types, Sublime Text will automatically activate this syntax definition for
them.
uuid :
This is a unique identifier for this syntax definition. Each new syntax definition
gets its own uuid. Even though Sublime Text itself ignores it, don’t modify this.
patterns :
A container for your patterns.
UUID 不用修改,舉個修改後的例子
comment : 這個就是註解
name : 這個是用來決定 highlight 的顏色,這邊只用了預設的值(可參考這裡)
match : 使用 regular expression 來定義 syntax
確認 Tools -> Build System 是選在 Autiomatic
然後按 F7 編譯,這樣就可以了
之後只要是指定的副檔名的檔案,都可以用自訂的 syntax rule 去呈現
沒有留言:
張貼留言