Home Download Buy Blog Forum Support

Change Color Scheme Depending On File Type Open

Change Color Scheme Depending On File Type Open

Postby sublime_user on Wed Aug 03, 2011 9:23 pm

I have a color scheme that I want to open for all .cfm files. But for .js files, I want the default Cobalt. In the same window, is there a way to switch to a specific Color Theme depending on the file I'm looking at (open)?

Thanks!
sublime_user
 
Posts: 13
Joined: Wed Aug 03, 2011 9:17 pm

Re: Change Color Scheme Depending On File Type Open

Postby C0D312 on Wed Aug 03, 2011 9:41 pm

You can do this in the "Syntax Specific - User" file under the preferences menu.
C0D312
 
Posts: 1063
Joined: Sun Jul 10, 2011 3:23 am

Re: Change Color Scheme Depending On File Type Open

Postby sublime_user on Wed Aug 03, 2011 10:19 pm

Thanks. Yeap, I can get to that file, but it comes up blank. What code do I put in there so that:

if I have a .cfm file open, switch to color scheme x
if I have a .js file open, switch to color scheme y
if I have a .pl file open, switch to color scheme z

Thanks.
sublime_user
 
Posts: 13
Joined: Wed Aug 03, 2011 9:17 pm

Re: Change Color Scheme Depending On File Type Open

Postby jps on Wed Aug 03, 2011 11:52 pm

Have a look in "Preferences/File Settings - Default" for a list of everything you can put in there. You want the color_scheme key:

Code: Select all
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme"
jps
Site Admin
 
Posts: 3077
Joined: Wed Mar 19, 2008 12:33 pm

Re: Change Color Scheme Depending On File Type Open

Postby sublime_user on Thu Aug 04, 2011 2:29 pm

Thanks. Excuse my ignorance.

I'm not sure how one would change that line of code so that it picks a color scheme depending on the type of file. I did not see any other settings in the default that would help.

Would one do something like this?

{
".cfm": "Packages/coldfusion.tmTheme",
".js": "Packages/js.tmTheme",
".pl": "Packages/perl.tmTheme"
}

Thanks again.
sublime_user
 
Posts: 13
Joined: Wed Aug 03, 2011 9:17 pm

Re: Change Color Scheme Depending On File Type Open

Postby jbjornson on Thu Aug 04, 2011 2:43 pm

When you have a ".js" file open, use the menu to open the syntax-specific settings file (Preferences / File Settings - More / Syntax Specific - User). If you look at the name of the file that has been opened, you should be able to see that this file is specific to JavaScript files (Packages/User/JavaScript.sublime-settings). Add the setting as jps suggested before and it should work as desired.

You will need to do this for each file type that you want to have special syntax highlighting.
jbjornson
 
Posts: 353
Joined: Tue Oct 27, 2009 4:25 pm
Location: Zurich, Switzerland

Re: Change Color Scheme Depending On File Type Open

Postby iamntz on Thu Aug 04, 2011 2:45 pm

@sublime_user: open a cfm file (or set syntax as cfm) then go to preferences -> file settings (more) -> syntax specific and add:
Code: Select all
{
   "color_scheme": "Packages/cfm/custom-theme.tmTheme"
}

Do the same for every language.

Enjoy!
iamntz
 
Posts: 917
Joined: Fri Apr 29, 2011 8:52 am
Location: Romania

Re: Change Color Scheme Depending On File Type Open

Postby sublime_user on Thu Aug 04, 2011 4:24 pm

Awesome! Thanks! Got it working.
sublime_user
 
Posts: 13
Joined: Wed Aug 03, 2011 9:17 pm


Return to Technical Support

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot] and 21 guests