Sublime Text 3:如何进行键绑定以启用和禁用 Anaconda linting?
Sublime Text 3: How do I make a keybind to enable and disable Anaconda linting?
我希望能够使用热键 enable/disable anaconda linting。每当我不得不使用它时都必须打开设置真的很不方便。我是 Sublime Text 的新手,但根据我在键绑定中看到的内容,您可以使用 args 传递变量。例如:
[{"keys": ["ctrl+q"], "command": "toggle_comment", "args": {"block": false}}]
所以,我在想,也许有一个命令可以更改包“settings - user”并传递一个 var 来将 ["anaconda_linting": false,] 设置为 true 或 false?
您可以使用自定义插件和键绑定来完成此操作。 Select Tools → Developer → New Plugin…
并将打开的文件内容设置为:
import sublime
import sublime_plugin
class ToggleAnacondaLintingCommand(sublime_plugin.ApplicationCommand):
def run(self):
s = sublime.load_settings("Anaconda.sublime-settings")
current = s.get("anaconda_linting")
new = not current
s.set("anaconda_linting", new)
sublime.save_settings("Anaconda.sublime-settings")
sublime.active_window().run_command('save')
按 CtrlS 进行保存,您的 Packages/User
文件夹应该会打开。将文件另存为 toggle_anaconda_linting.py
.
现在,打开您的快捷键并在 [ ]
个字符之间添加以下内容(选择您想要的任何快捷方式):
{"keys": ["ctrl+alt+shift+l"], "command": "toggle_anaconda_linting"},
现在,只要您点击快捷方式,所有文件的 "anaconda_linting"
都会切换。
我希望能够使用热键 enable/disable anaconda linting。每当我不得不使用它时都必须打开设置真的很不方便。我是 Sublime Text 的新手,但根据我在键绑定中看到的内容,您可以使用 args 传递变量。例如:
[{"keys": ["ctrl+q"], "command": "toggle_comment", "args": {"block": false}}]
所以,我在想,也许有一个命令可以更改包“settings - user”并传递一个 var 来将 ["anaconda_linting": false,] 设置为 true 或 false?
您可以使用自定义插件和键绑定来完成此操作。 Select Tools → Developer → New Plugin…
并将打开的文件内容设置为:
import sublime
import sublime_plugin
class ToggleAnacondaLintingCommand(sublime_plugin.ApplicationCommand):
def run(self):
s = sublime.load_settings("Anaconda.sublime-settings")
current = s.get("anaconda_linting")
new = not current
s.set("anaconda_linting", new)
sublime.save_settings("Anaconda.sublime-settings")
sublime.active_window().run_command('save')
按 CtrlS 进行保存,您的 Packages/User
文件夹应该会打开。将文件另存为 toggle_anaconda_linting.py
.
现在,打开您的快捷键并在 [ ]
个字符之间添加以下内容(选择您想要的任何快捷方式):
{"keys": ["ctrl+alt+shift+l"], "command": "toggle_anaconda_linting"},
现在,只要您点击快捷方式,所有文件的 "anaconda_linting"
都会切换。