Reputation: 378
I want to be able to use a hotkey to enable/disable anaconda linting. Its really inconvenient to have to open the settings whenever I had to use it. I'm new to Sublime Text but from what I see at the Keybindings, you can pass a variable with the args. For example:
[{"keys": ["ctrl+q"], "command": "toggle_comment", "args": {"block": false}}]
So, I was thinking, maybe there's a command to change package "settings - user" and pass a var to set ["anaconda_linting": false,] into true or false?
Upvotes: 2
Views: 346
Reputation: 102902
You can do this with a custom plugin and keybinding. Select Tools → Developer → New Plugin…
and set the contents of the file that opens to this:
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')
Hit CtrlS to save, and your Packages/User
folder should open up. Save the file as toggle_anaconda_linting.py
.
Now, open up your keybindings and add the following between the [ ]
characters (choosing whatever shortcut you want):
{"keys": ["ctrl+alt+shift+l"], "command": "toggle_anaconda_linting"},
Now, whenever you hit the shortcut, "anaconda_linting"
will be toggled for all files.
Upvotes: 3