2014-02-08 69 views
1

我使用的崇高文本編輯器3爲Linux。我用它來編寫Python的代碼。我希望能夠將文檔字符串的顏色更改爲其他顏色而不更改常規註釋的顏色(#)。我查看了.tmTheme文件,但在那裏我無法找到關於文檔字符串顏色的內容。然而,有一個主題顯然對文檔字符串和常規評論有兩種不同的顏色。崇高的文本編輯器3 - 主題 - 更改文檔字符串顏色

​​

我怎樣才能修改一個主題,這樣的文檔字符串和註釋有兩種不同的顏色?

回答

1

我開發了Neon Color SchemePython Improved語言定義,以儘可能多的範圍儘可能多地使Python特別是儘可能多的其他語言看起來儘可能好。它還包括文檔字符串不同的顏色和評論:

Neon and Python Improved

這裏是在.tmTheme文件中的條目文檔字符串:

<dict> 
    <key>name</key> 
    <string>docstring</string> 
    <key>scope</key> 
    <string>string.quoted.double.block, string.docstring, string.quoted.single.block</string> 
    <key>settings</key> 
    <dict> 
     <key>fontStyle</key> 
     <string>italic</string> 
     <key>foreground</key> 
     <string>#218B97</string> 
    </dict> 
</dict> 

和定期評論:

<dict> 
    <key>name</key> 
    <string>Comment</string> 
    <key>scope</key> 
    <string>comment</string> 
    <key>settings</key> 
    <dict> 
     <key>fontStyle</key> 
     <string>italic</string> 
     <key>foreground</key> 
     <string>#7F817E</string> 
    </dict> 
</dict> 

而且,如果你想讓你的引號脫穎而出:

<dict> 
    <key>name</key> 
    <string>String Quotes</string> 
    <key>scope</key> 
    <string>string.quoted punctuation.definition.string.begin, string.quoted punctuation.definition.string.end</string> 
    <key>settings</key> 
    <dict> 
     <key>fontStyle</key> 
     <string>italic</string> 
     <key>foreground</key> 
     <string>#FF07A2</string> 
    </dict> 
</dict> 
+0

我喜歡你定義了很多範圍,但是NEON顏色方案太暗了。我仍然可以從範圍定義中受益嗎? – Vader

+0

你可以加入嗎? http://chat.stackoverflow.com/rooms/47093/sublime-text-stuff – Vader

0

我發現this answer基本上建議你改變你的tmTheme一個條目:在Comment定義,添加蟒蛇文檔字符串字符串。

<dict> 
     <key>name</key> 
     <string>Comment</string> 
     <key>scope</key> 
     <string>comment, string.quoted.double.block.python</string> 
     <key>settings</key> 
     <dict> 
      <key>foreground</key> 
      <string>#757575</string> 
     </dict> 
    </dict> 

要改變你的tmTheme容易,PackageResourceViewer(在this question在接受答覆中提到)的偉大工程。

這會將您的文檔字符串更改爲與註釋相同的顏色。我還沒有測試過這個,但我假設有一個新的定義,如

<dict> 
     <key>name</key> 
     <string>Python-Docstring</string> 
     <key>scope</key> 
     <string>string.quoted.double.block.python</string> 
     <key>settings</key> 
     <dict> 
      <key>foreground</key> 
      <string>#FFFFFF</string> 
     </dict> 
    </dict> 

將允許你指定一種新的顏色。

-1

我知道這個線程是舊的,但我有這個相同的確切問題,無法改變顏色。所以這就是它對我的工作原理,我希望它能幫助別人。這些都是我通過資源觀衆把線:

<dict> 
     <key>name</key> 
     <string>docstring</string> 
     <key>scope</key> 
     <string>string.quoted.double.block, comment.block.documentation, string.quoted.single.block</string> 
     <key>settings</key> 
     <dict> 
      <key>fontStyle</key> 
      <string>italic</string> 
      <key>foreground</key> 
      <string>#03FFA7</string> 
     </dict> 
    </dict> 

<dict> 
     <key>name</key> 
     <string>String Quotes</string> 
     <key>scope</key> 
     <string>comment.block.documentation punctuation.definition.comment.begin, comment.block.documentation punctuation.definition.comment.end, 
       ,string.quoted punctuation.definition.string.begin, string.quoted punctuation.definition.string.end</string> 
     <key>settings</key> 
     <dict> 
      <key>fontStyle</key> 
      <string>italic</string> 
      <key>foreground</key> 
      <string>#1FFF0F</string> 
     </dict> 
    </dict> 
0

如果你想修改默認的顏色方案中的一種,你應該遵循這個答案上StackOverflow有關安裝PackageResourceViewer,這將讓你打開默認的配色方案,編輯它。一旦安裝了PackageResourceViewer,只需按⌘+ Shift + P並搜索PackageResourceViewer:Open Resource → Color Scheme - Default → THEME其中THEME是您想要編輯的主題。這將打開一個.tmTheme文件,其中包含該主題的所有當前設置。如果您想要更改任何語言特定的語法突出顯示,您需要知道sublime-syntax文件調用您想要更改的語法的名稱。syntax definition files for Sublime Text託管在GitHub上,並顯示哪個正則表達式用於定義該語言的各種語法。要更改Python語言文檔字符串,我們可以查看Python.sublime-syntax文件,它說meta_scope: comment.block.documentation.python。這意味着我們需要使用comment.block.documentation.python作爲我們的.tmTheme文件中的設置範圍,我們可以給它任何我們想要的設置。因此,要改變文檔字符串此段文字應添加到您的.tmTheme文件:

<dict> 
    <key>name</key> 
    <string>Python-Docstring</string> 
    <key>scope</key> 
    <string>comment.block.documentation.python</string> 
    <key>settings</key> 
    <dict> 
     <key>foreground</key> 
     <string>#FFFFFF</string> 
    </dict> 
</dict> 

我們指明這種風格的變化Python的文檔字符串(本場是由崇高文本忽略)的名稱,我們告訴它我們將通過將範圍設置爲comment.block.documentation.python來爲python使用中的文檔語句突出顯示語法,並且我們正在更改該範圍中的設置以使前景文本爲#FFFFFF。我建議將該文件保存在/Users/USERNAME/Library/Application Support/Sublime Text 3/Packages/User中,以便將來訪問更容易,並且不會覆蓋默認主題。最後在Sublime Text中,你去Sublime Text → Preferences → Color Scheme並選擇你的主題!