Sublime Forum

Toggle "preview_on_click" not working

#1

I have this keyboard command:

{"keys":["alt+v"], "command":"toggle_setting", "args":{"setting":"preview_on_click"}},

But when I press alt+v nothing is happening, setting stays the same.

0 Likes

#2

toggle_setting toggles a setting for the currently focused file, it doesn’t work for application settings. I don’t think there’s a built-in command that does what you want, you’d need a plugin to do this.

0 Likes

#3

I guess I will have to learn to to write plugins then. Because there are some things that I need, but can’t find them in packages.

0 Likes

#4

@IGRACH
I am not sure to do things in an optimal way, but I have a command for this.
I have the following in my Packages/User/my_commands.py file:

import sublime
import sublime_plugin
class TogglePreviewOnClick(sublime_plugin.ApplicationCommand):
    def run(self):
        prefs = sublime.load_settings("Preferences.sublime-settings")
        prefs.set("preview_on_click", not prefs.get("preview_on_click"))
        sublime.save_settings("Preferences.sublime-settings")

With that you can set in your sublime-keymap file:

   {"keys":["alt+v"], "command":"toggle_preview_on_click"},
1 Like

#5

Thank you xD

0 Likes