get in touch w/ IT via woowie

Toggle Whitespace in Sublime Text 2

A simple way to create a shortcut for toggling show_white_spaces in Sublime Text 2. Credits facelessuser

Installation

Tools -> new Plugin

import sublime
import sublime_plugin


class ToggleWhiteSpaceCommand(sublime_plugin.ApplicationCommand):
    def run(self):
        settings = sublime.load_settings("Preferences.sublime-settings")
        white_space = "selection" if settings.get("draw_white_space", "selection") != "selection" else "all"
        settings.set("draw_white_space", white_space)
        sublime.save_settings("Preferences.sublime-settings")

Save as toogle_white_space.py, then open up User Key Bindings, by

Preferences -> Key Bindings User, and add this:

[
  {
    "keys": ["ctrl+alt+w"], "command": "toggle_white_space"
  }
]

ctrl+alt+w is the same what i use in WebStorm.

Thats it, try out :)

comments powered by Disqus