Sublime Forum

Why can't I turn off hidden characters easily?

#1

I use stylus css preprocessors. It’s based around white space indentations. Whenever sublime detects a .styl file it starts showing hidden characters making it VERY hard for me to read my code.

How can I turn this off? Isn’t there a quick way to toggle this on/off?

Please help, I’m losing my mind: screenshot

0 Likes

#2

I had to go into the stylus library in packages and edit Stylus.sublime-settings, with:

{
“draw_white_space”: “none”
}

HOW can I please toggle whitespace ON AND OFF with keyboard or menu? I want it off except when I need it on for a minute to debug a issue.

0 Likes

#3

As a side note, you can create Stylus.sublime-settings in your user directory so you don’t have to edit the installed package. This holds true for any user specific settings. Now onto your original question.

This can be done easily with a plugin. First, create a new plugin (in the menu select Tools -> New Plugin). Paste the following code and save. This should be saved in your user directory. You may name the file whatever you want, just ensure it is saved as a python file.

[code]import sublime_plugin

class ToggleDrawWhiteSpaceCommand(sublime_plugin.TextCommand):
def run(self, edit):
settings = self.view.settings()
setting = settings.get(“draw_white_space”)
if setting == “all”:
settings.set(“draw_white_space”, “none”)
else:
settings.set(“draw_white_space”, “all”)
[/code]

Next, add the following to your user keybinding (Accessible through Preferences -> Key Bindings - User) and add the following

{ "keys": "f12"], "command": "toggle_draw_white_space" }

Of course, you can change the keybinding to whatever you want.

0 Likes

#4

Thanks for the tip on creating a plugin. I really appreciate it.

That said, I’m assuming there is no easy way to toggle on and off for the current document. Sublime developers, if your listening this is a “Basic Must Have feature” for any editor

0 Likes

#5

doesn’t work :frowning: does it matter what I named the saved file? just doesn’t work with shortcut at all…

[quote=“skuroda”]As a side note, you can create Stylus.sublime-settings in your user directory so you don’t have to edit the installed package. This holds true for any user specific settings. Now onto your original question.

This can be done easily with a plugin. First, create a new plugin (in the menu select Tools -> New Plugin). Paste the following code and save. This should be saved in your user directory. You may name the file whatever you want, just ensure it is saved as a python file.

[code]import sublime_plugin

class ToggleDrawWhiteSpaceCommand(sublime_plugin.TextCommand):
def run(self, edit):
settings = self.view.settings()
setting = settings.get(“draw_white_space”)
if setting == “all”:
settings.set(“draw_white_space”, “none”)
else:
settings.set(“draw_white_space”, “all”)
[/code]

Next, add the following to your user keybinding (Accessible through Preferences -> Key Bindings - User) and add the following

{ "keys": "f12"], "command": "toggle_draw_white_space" }

Of course, you can change the keybinding to whatever you want.[/quote]

0 Likes

#6

Odd I just retested it (copy pasting from what I had put here before) and it works okay. The name of the file shouldn’t matter. Did you save it in “Packages/User” directory? In the ST console, type the following command “sublime.log_commands(True)”. Then press your keybinding. What comes up for the command? Are there any errors?

0 Likes