Sublime Forum

Filename-specific settings

#1

Hello everyone

I want to disable word-wrap option for some specifics files such as fonts.scss in which i have very long base64 lines (d.pr/i/14zDN). Is it posiible?

0 Likes

#2

You can make settings different for every file type.
Open a file with the wished file type.

This opens a settings file for this file type. Here you can make all settings for this.

[quote] // Disables horizontal scrolling if enabled.
// May be set to true, false, or “auto”, where it will be disabled for
// source code, and otherwise enabled.
“word_wrap”: “auto”,[/quote]

EDIT:

If you need special settings for some files of the same file type, try this. Create a new plugin, insert the following code.
But its not tested, i’m not on my PC.

[code]import sublime
import sublime_plugin
import os.path as osp

SETTINGS_FILE = “CSS.sublime-settings”
‘’’
settings should include following:

"extensions":

    "css"
],
// here the pathes of files with different settings
"special_files":

    "C:\\Path1\\Filename1.css",
    "C:\\Path2\\Filename2.css",
    "C:\\Path3\\Filename3.css"
],
// here the special settings for this files
"special_settings":
{
    "word_wrap": false
},
// here this settings as default
"default_settings":
{
    "word_wrap": "auto"
},
// here again the default value(s) to load from all files
"word_wrap": "auto",

‘’’
settings = None

class EventListener(sublime_plugin.EventListener):
def on_load(self, view):
curr_full_path = sublime.active_window().active_view().file_name()
ext = osp.splitext(curr_full_path)[1]
if ext not in settings.get(“extensions”):
return
special = settings.get(“special_settings”)
if curr_full_path in settings.get(“special_files”):
# do it for all key-value pairs from special_settings
settings.set(“word_wrap”, special.get(“word_wrap”))
else:
# check only if one key has special_value - than all values needs reset
if settings.get(“word_wrap”) == special.get(“word_wrap”):
default = settings.get(“default_settings”)
# do it for all key-value pairs from special_settings
settings.set(“word_wrap”, default.get(“word_wrap”))

def plugin_loaded():
global settings
settings = sublime.load_settings(SETTINGS_FILE)
[/code]

0 Likes