2012-10-24 84 views

回答

11

您可以在用戶的​​鍵綁定設置(菜單Sublime Text 2/Preferences/Key Bindings - User)補充一點:

{ 
    "keys": ["YOUR_ENABLE_RULERS_SHORTCUT"], 
    "command": "set_setting", 
    "args": 
    { 
    "setting": "rulers", 
    "value": [80, 120] 
    } 
} 

要禁用統治者:

{ 
    "keys": ["YOUR_DISABLE_RULERS_SHORTCUT"], 
    "command": "set_setting", 
    "args": 
    { 
    "setting": "rulers", 
    "value": [] 
    } 
} 

如果你真的想要一個切換,你可以創建一個新的插件(Tools/New Plugin...),代碼與此類似:

import sublime, sublime_plugin 

class ToggleRulersCommand(sublime_plugin.TextCommand): 
    def run(self, edit, **kwargs): 
     rulers = kwargs["values"] if self.view.settings().get("rulers") == [] else [] 
     self.view.settings().set("rulers", rulers) 

Sa請在您的Packages/User目錄中使用插件,名稱爲ToggleRulers.py

然後,添加此鍵綁定:

{ 
    "keys": ["YOUR_TOGGLE_RULERS_SHORTCUT"], "command": "toggle_rulers", 
    "args": { "values": [80, 120] } 
} 
+0

謝謝。插件的答案是完美的。我將它映射到shift + option + r(沒有默認衝突並且易於觸及) – Jon

相關問題