[英]Is there a way to use different Sublime Text themes for different file sources?
我想在ST3中設置兩個單獨的主題。 一個主題用於本地文件,第二個主題用於通過我的FTP應用程序打開的任何文件(傳輸)。 這可能嗎?
最簡單的解決方案可能是覆蓋來自FTP緩存文件夾的任何文件。 但是我不知道這是否可能。
是的,這可以通過相當簡單的插件實現。 在Sublime中打開一個新的Python文件,並添加以下內容:
import sublime
import sublime_plugin
class TransmitColorSchemeCommand(sublime_plugin.TextCommand):
def run(self, edit):
if "/path/to/transmit/tempfiles" in self.view.file_name():
self.view.settings().set("color_scheme", "Packages/Color Scheme - Default/Monokai.tmTheme")
class TransmitEventListener(sublime_plugin.EventListener):
def on_load_async(self, view):
view.run_command("transmit_color_scheme")
確保將"/path/to/transmit/tempfiles"
為所需的實際路徑,並將"color_scheme"
設置更改為要用於傳輸文件的配色方案。 將文件另存為Packages/User/transmit_color_scheme.py
,其中Packages
是在選擇Preferences -> Browse Packages...
菜單選項時打開的文件夾。 在OS X上,它是~/Library/Application Support/Sublime Text 3/Packages
。
保存后,事件偵聽器將立即啟動,並且您打開的包含指定路徑的任何文件都會將顏色方案設置為您指定的顏色。 來自其他路徑的所有其他文件將使用您的默認配色方案。
玩得開心!
請注意,此插件僅在ST3中可用。 要使其在ST2中工作, def on_load_async
def on_load
更改為def on_load
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.