如何让 WebStorm IDE 正确识别文件类型? [英] How to make WebStorm IDE to correctly recognise file type?
问题描述
(在 JetsBrains/WebStorm IDE 中)最初我创建了一个名为
HelloWorldContainer
的文件 - 不小心遗漏了.js
扩展名(我打算创建HelloWorldContainer.js
).
(Within JetsBrains / WebStorm IDE) Initially I created a file called
HelloWorldContainer
- accidentally left out the.js
extension (I meant to createHelloWorldContainer.js
).
WebStorm 询问我希望该文件是什么文件类型(例如 JavaScript?文本文件?HTML?等).我不小心按了回车键 - WebStorm 将其视为文本文件.
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.
意识到我的错误后,我将文件重命名为 HelloWorldContainer.js
(将 .js
添加到末尾`).希望这会将文件类型改回 JavaScript 文件.
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.
问题
出于某种原因,WebStorm 仍在看到"HelloWorldContainer.js
作为文本文件???(截图如下).这是一个问题,因为现在我的 JavaScript 实时模板不再为此文件加载.
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.
快照 1:将 HelloWorld.js
显示为 JavaScript 文件,而 HelloWorldContainer.js
显示为文本文件(嗯?).
Snapshot 1: showing HelloWorld.js
as a JavaScript file, whilst HelloWorldContainer.js
showing as a text file (huh?).
快照 2:对于 HelloWorld.js
,WebStorm 知道它是一个 JavaScript 文件 - 结果实时模板成功加载.(Cmd + J)
Snapshot 2: for HelloWorld.js
, WebStorm knows it is a JavaScript file - Live Templates successfully loaded as a result. (Cmd + J)
快照 3:对于 HelloWorldContainer.js
,WebStorm(出于某种原因)无法将其识别为 JavaScript 文件 - 因此无法加载 JavaScript 实时模板.(Cmd + J)
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)
如何让 WebStorm 再次将 HelloWorldContainer.js
识别为 JavaScript 文件?
How to I make WebStorm recognise HelloWorldContainer.js
as a JavaScript file again?
注意:我已经尝试过...
Note: I've tried...
- 删除
HelloWorldContainer.js
并重新创建它,WebStorm 仍将其视为文本文件. - 将
HelloWorldContainer.js
重命名为HelloWorldContainer2.js
- WebStorm 现在将其视为 JavaScript 文件.但是,如果我将其重命名回原始名称,WebStorm 会再次将其视为文本文件.(我真的很想调用我的文件HelloWorldContainer.js
!:-)
- delete the
HelloWorldContainer.js
and recreate it again, WebStorm is still seeing it as a text file. - rename
HelloWorldContainer.js
toHelloWorldContainer2.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 fileHelloWorldContainer.js
! :-)
刚刚尝试了下面提供的解决方案(由@LazyOne 提供)- 很有魅力!一些用于记笔记的快照...
Just tried out the solution provided below (by @LazyOne)- works like a charm! Some snapshots for note keeping...
快照 4:删除违规模式.
Snapshot 4: remove the offending pattern.
快照 5:WebStorm 现在再次将文件视为 JavaScript!
Snapshot 5: WebStorm now sees the file as a JavaScript again!
推荐答案
设置/首选项 |编辑 |文件类型
- 在顶部列表中找到
Text
条目 - 从底部列表中删除违规模式 -- 很可能是
HelloWorldContainer.js
或非常相似的 - 点击
OK
并等待项目被重新索引.
Settings/Preferences | Editor | File Types
- Locate
Text
entry in top list - Remove offending pattern from bottom list -- most likely will be
HelloWorldContainer.js
or very similar - Hit
OK
and wait till project will be re-indexed.
这篇关于如何让 WebStorm IDE 正确识别文件类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!