Home Download Buy Blog Forum Support

How can i set the default syntax for files?

How can i set the default syntax for files?

Postby technobulka on Mon Apr 16, 2012 8:04 am

I want to set the default html syntax for *.xtpl / *.tpl / etc.
How can i do this?
technobulka
 
Posts: 15
Joined: Wed Mar 28, 2012 6:32 pm

Re: How can i set the default syntax for files?

Postby technobulka on Thu Apr 19, 2012 4:33 pm

still can't find it :(
technobulka
 
Posts: 15
Joined: Wed Mar 28, 2012 6:32 pm

Re: How can i set the default syntax for files?

Postby burksa on Thu Apr 19, 2012 7:03 pm

On OS X you can change the "fileTypes" dictionary in the ~/Library/Application Support/Sublime Text 2/Packages/HTML/HTML.tmLanguage file. Simply add a new entry for the file types you're interested in:

Code: Select all
   <key>fileTypes</key>
   <array>
      <string>html</string>
      <string>htm</string>
      <string>shtml</string>
      <string>xhtml</string>
      <string>phtml</string>
      <string>inc</string>
      <string>tmpl</string>
      <string>tpl</string>
      <string>ctp</string>
      <string>xtpl</string> <!-- added this line for *.xtpl support -->
   </array>

It's probably a similar process on Windows and Linux, you just need to find where Sublime Text 2 stores its Packages.
burksa
 
Posts: 2
Joined: Thu Apr 19, 2012 6:48 pm

Re: How can i set the default syntax for files?

Postby technobulka on Thu Apr 19, 2012 7:44 pm

burksa, thank you very much!
In Win7 it file there - C:\Users\{UserName}\AppData\Roaming\Sublime Text 2\Packages\HTML\HTML.tmLanguage
And in Sublime - Preferences -> Brose Packages...
technobulka
 
Posts: 15
Joined: Wed Mar 28, 2012 6:32 pm

Re: How can i set the default syntax for files?

Postby phillip.koebbe on Thu Apr 19, 2012 9:28 pm

If you don't want to change syntax files, you could try DetectSyntax [1] or do something similar.

[1] https://github.com/phillipkoebbe/DetectSyntax
-- Phillip

Code: Select all
while self.living? do
    mistake = Mistake.new
    self.learn_from!(mistake) unless mistake.fatal?
end
phillip.koebbe
 
Posts: 208
Joined: Tue Dec 20, 2011 4:58 pm

Re: How can i set the default syntax for files?

Postby jps on Fri Apr 20, 2012 2:24 am

Alternatively, you can use the "View/Syntax/Open all with current Extension as.." menu
jps
Site Admin
 
Posts: 3071
Joined: Wed Mar 19, 2008 12:33 pm

Re: How can i set the default syntax for files?

Postby cgibby on Wed Apr 25, 2012 5:54 pm

I have the same question. I'm trying to get .ctp files automatically recognized as "HTML (PHP Cake)" and I have that option checked in the "Open all with current Extension as..." submenu, but every time I reopen one of those files, it reverts to the "PHP" syntax. I also have a DetectSyntax rule set up (see code below), but that doesn't seem to do it either.

Code: Select all
   {
      "name": "PHP",
      "rules": [
         {"file_name": ".*\\.(php|inc)$"},
         {"first_line": "^<\\?php"}
      ]
   },
   {
      "name": "HTML (PHP Cake)",
      "rules": [
         {"file_name": ".*\\.(ctp|thtml)$"}
      ]
   },
cgibby
 
Posts: 5
Joined: Thu Feb 02, 2012 3:54 pm

Re: How can i set the default syntax for files?

Postby phillip.koebbe on Thu Apr 26, 2012 12:16 am

cgibby wrote:I have the same question. I'm trying to get .ctp files automatically recognized as "HTML (PHP Cake)" and I have that option checked in the "Open all with current Extension as..." submenu, but every time I reopen one of those files, it reverts to the "PHP" syntax. I also have a DetectSyntax rule set up (see code below), but that doesn't seem to do it either.

Code: Select all
   {
      "name": "PHP",
      "rules": [
         {"file_name": ".*\\.(php|inc)$"},
         {"first_line": "^<\\?php"}
      ]
   },
   {
      "name": "HTML (PHP Cake)",
      "rules": [
         {"file_name": ".*\\.(ctp|thtml)$"}
      ]
   },


Will you please create an issue [1] for this? Please paste your complete DetectSyntax.sublime-settings and a sample CTP file as gists and link to them in the issue. If you would also provide all pertinent information like platform, version, etc etc (anything that could be useful), I'd really appreciate it. I'll dig in and see if I can figure out why DetectSyntax didn't get the right syntax assigned.

[1] https://github.com/phillipkoebbe/DetectSyntax/issues
-- Phillip

Code: Select all
while self.living? do
    mistake = Mistake.new
    self.learn_from!(mistake) unless mistake.fatal?
end
phillip.koebbe
 
Posts: 208
Joined: Tue Dec 20, 2011 4:58 pm

Re: How can i set the default syntax for files?

Postby oXide on Fri May 17, 2013 8:05 am

Thank you very much ! :D
oXide
 
Posts: 1
Joined: Fri May 17, 2013 8:04 am


Return to Technical Support

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 30 guests