Search code examples
webstorm

How to make WebStorm IDE to correctly recognise file type?


 The Background

  1. (Within JetsBrains / WebStorm IDE) Initially I created a file called HelloWorldContainer - accidentally left out the .js extension (I meant to create HelloWorldContainer.js).

  2. WebStorm asks what file type I would like that file to be (e.g. JavaScript? Text File? HTML? etc.). I accidentally hit the enter key - and WebStorm has treated it as a text file.

  3. Realising my mistake, I renamed the file to HelloWorldContainer.js (adding that .js to the end`). Hoping this will change the file type back to a JavaScript file.

The Problem

For some reason, WebStorm is still "seeing" HelloWorldContainer.js as a text file??? (snapshot below). This is a problem as now my JavaScript Live Templates no longer load for this file.

Snapshot 1: showing HelloWorld.js as a JavaScript file, whilst HelloWorldContainer.js showing as a text file (huh?).

enter image description here

Snapshot 2: for HelloWorld.js, WebStorm knows it is a JavaScript file - Live Templates successfully loaded as a result. (Cmd + J)

enter image description here

Snapshot 3: for HelloWorldContainer.js, WebStorm (for some reason) fail to recognise it as a JavaScript file - the JavaScript Live Templates fail to load as a result. (Cmd + J)

enter image description here

How to I make WebStorm recognise HelloWorldContainer.js as a JavaScript file again?

Note: I've tried...

  • delete the HelloWorldContainer.js and recreate it again, WebStorm is still seeing it as a text file.
  • rename HelloWorldContainer.js to HelloWorldContainer2.js - WebStorm now sees it as a JavaScript file. But if I rename it back to original name, WebStorm sees it as a text file again. (I really want to call my file HelloWorldContainer.js! :-)

The Solution

Just tried out the solution provided below (by @LazyOne)- works like a charm! Some snapshots for note keeping...

Snapshot 4: remove the offending pattern.

enter image description here

Snapshot 5: WebStorm now sees the file as a JavaScript again!

enter image description here


Solution

    1. Settings/Preferences | Editor | File Types
    2. Locate Text entry in top list
    3. Remove offending pattern from bottom list -- most likely will be HelloWorldContainer.js or very similar
    4. Hit OK and wait till project will be re-indexed.