Every New File to be seen as a JavaScript file by default


I looked around for other similar questions and I found some partial answers but none that have to do with JavaScript, nor did I find any documentation on possible languages or their syntax and so on…

So my question is, what do I need to put into my “init.coffee” file in order for every file created to be seen as a JavaScript one by default since now it is set to Plain Text?



It doesn’t matter what the language is, the process is always the same.

atom.workspace.observeTextEditors (editor) ->
  if editor.getTitle() == "untitled"
    editor.setGrammar(atom.grammars.grammarForScopeName "source.js")

Any language is possible, and if you want to find the scope for a language, you can locate it via Settings -> Packages or by looking at the source code for the language package.