Home Download Buy Blog Forum Support

Why can't I turn off hidden characters easily?

Why can't I turn off hidden characters easily?

Postby ckizer on Fri Feb 15, 2013 6:57 pm

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
Image
ckizer
 
Posts: 19
Joined: Mon Mar 12, 2012 10:26 pm

Re: Why can't I turn off hidden characters easily?

Postby ckizer on Fri Feb 15, 2013 7:01 pm

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.
ckizer
 
Posts: 19
Joined: Mon Mar 12, 2012 10:26 pm

Re: Why can't I turn off hidden characters easily?

Postby skuroda on Sat Feb 16, 2013 3:02 am

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: Select all
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")


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

Code: Select all
{ "keys": ["f12"], "command": "toggle_draw_white_space" }


Of course, you can change the keybinding to whatever you want.
skuroda
 
Posts: 685
Joined: Fri Oct 05, 2012 8:11 am

Re: Why can't I turn off hidden characters easily?

Postby ckizer on Mon Feb 18, 2013 11:56 pm

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
ckizer
 
Posts: 19
Joined: Mon Mar 12, 2012 10:26 pm

Re: Why can't I turn off hidden characters easily?

Postby ckizer on Mon Feb 18, 2013 11:58 pm

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


skuroda wrote: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: Select all
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")


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

Code: Select all
{ "keys": ["f12"], "command": "toggle_draw_white_space" }


Of course, you can change the keybinding to whatever you want.
ckizer
 
Posts: 19
Joined: Mon Mar 12, 2012 10:26 pm

Re: Why can't I turn off hidden characters easily?

Postby skuroda on Tue Feb 19, 2013 1:11 am

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?
skuroda
 
Posts: 685
Joined: Fri Oct 05, 2012 8:11 am


Return to General Discussion

Who is online

Users browsing this forum: Clams and 13 guests