1

I'm opening .RUL files in Sublime Text which do not have any syntax highlighting, since InstallScript has a similar syntax to C/C++ I want all my .rul files to be treated as if they were .c or .cpp files and automatically have all the same highlighting applied to them. In other words: I want to have the same effect as if I renamed each .rul file to .cpp and then opened the .cpp in Sublime.

What's the easiest way to implement this in Sublime Text 2.0.2 ?

Nothing 2 Lose
  • 180
  • 1
  • 3
  • 8
  • possible duplicate of [Set default syntax to different filetype in Sublime Text 2](http://stackoverflow.com/questions/7574502/set-default-syntax-to-different-filetype-in-sublime-text-2) – Ronin Oct 10 '13 at 17:12

4 Answers4

3

You can open the file in Sublime Text and use menu "View" → "Syntax" → "Open all with current extension as..." → (select appropriate syntax).

Also, you can click on right bottom corner of the window. This will open similar menu, where "Open all with current extension as..." is presented too.

Ronin
  • 1,688
  • 1
  • 13
  • 23
1

I'm not sure if the other solutions posted above will apply to all future instances of *.rul files, OR only to the currently open file.

I found a solution that works perfectly fine for me, just edit: ...\Application Data\Sublime Text 2\Packages\C++\C.tmLanguage

<key>fileTypes</key>
<array>
    <string>c</string>
    <string>h</string>
    <string>rul</string>

According to: http://docs.sublimetext.info/en/sublime-text-2/reference/syntaxdefs.html

fileTypes

This is a list of file extensions (without the leading dot). When opening files of these types, Sublime Text will automatically activate this syntax definition for them. Optional.
Nothing 2 Lose
  • 180
  • 1
  • 3
  • 8
0

Press Ctrl+Shift+P and type C++, highlight Set Syntax: C++ and press Enter.

Or go to View menu > Syntax > Click C++.

Bibhas Debnath
  • 14,559
  • 17
  • 68
  • 96
0

/Users/HOME/Library/Application Support/Sublime Text 2/Packages/C++/C++.sublime-settings

{
    "extensions": ["cpp", "cc", "cxx", "c++", "h", "hpp", "hxx", "h++", "inl", "ipp", "rul"]
}

Or, create a similar file and place it in your User directory, for rul and any other additional extensions not defined in the file mentioned hereinabove:

/Users/HOME/Library/Application Support/Sublime Text 2/Packages/User/C++.sublime-settings

{
    "extensions": ["rul"]
}
lawlist
  • 13,099
  • 3
  • 49
  • 158