Various features, including syntax highlighting, are dependent on the type of file that you’re editing. For example DOCTYPE
is only special inside of HTML files, and closing a tag with </
only makes sense in files that contain tags, such as HTML or XML.
If you just open Sublime and start typing, it assumes you’re editing a plain text file until you tell it differently, which is visualized in the status bar in the bottom right, where you will see it say Plain text
.
In order to tell Sublime that what you’re editing is HTML (for example) you need to do one of the following things:
- Save the file with an appropriate extension (e.g.
.html
) so that Sublime knows what sort of file it is.
- Click where it says
Plain text
in the status line, which opens a menu that allows you to select the appropriate syntax for the file that you’re editing
- Select
View > Syntax
from the main menu and pick the appropriate file type there (you get the same menu as mentioned in the previous step when you do this)
- Open the command palette (
Tools > Command Palette
or the associated key which is visible next to the menu item) and enter syn:
to filter the command list to just commands for changing the syntax, then pick the appropriate syntax (you can type a partial name to filter further).