Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make a default syntax by filetype in Atom text editor?

Tags:

atom-editor

I want my .ejs files to have html syntax, however, it always opens the files as Plain Text.

In sublime you can choose "Open all with current extension as..." then choose your syntax.

sublime text3 syntax

I see that you can change the syntax in the left bottom cornersyntax change

How do you open files with a certain type with a specific syntax?

like image 845
NathanBrakk Avatar asked Mar 12 '14 20:03

NathanBrakk


People also ask

How do you auto format an Atom?

To format all lines from a file, just use: Ctrl+Shift+F .

How do you change Atom preferences?

You can open the Settings View by navigating to Edit > Preferences (Linux), Atom > Preferences (macOS), or File > Settings (Windows).

Is Atom being discontinued?

We are archiving Atom and all projects under the Atom organization for an official sunset on December 15, 2022.


2 Answers

This is now in Atom core, you don't need that file-types package any more.

Where I work, we use .phl for a certain kind of PHP file. To tell Atom about this, first find the language's Scope Name (e.g. text.html.php ), then edit config.cson like so:

core:     customFileTypes:       "text.html.php": [         "phl"       ]     themes: [ // snip 

You can find this file at ~/.atom/config.cson, or from the Settings window click the "Open Config Folder" button.

It's easy to get wrong, as evidenced by the many errors people made on the GitHub issue for the feature.

like image 150
timseal Avatar answered Oct 22 '22 19:10

timseal


Edit: since the time I wrote this answer, this functionality has been added to Atom core, see this answer for details.

file-types Atom package

(https://atom.io/packages/file-types)

It does exactly what the title question asks for: you can define new file extensions for existing languages with a simple edit of the config.cson file.

like image 39
Ábel Hegedüs Avatar answered Oct 22 '22 18:10

Ábel Hegedüs