如何更改 WebStorm 中现有文件的文件类型关联? [英] How can I change the file type association of an existing file in WebStorm?
问题描述
我不小心创建了一个没有扩展名的文件,我选择了错误的文件类型关联.我认为的文本文档.我将它重命名为我想要的 .js 扩展名,但现在它没有任何语法高亮显示.WebStorm 不会将其视为 javascript 文件.我找不到任何地方可以更改 WebStorm 处理此文件的方式.我试过重命名它并重新命名它,但这不起作用.使用任何其他名称(带有 .js 扩展名),它会将其视为 javascript 文件,而不是原始名称.
I accidentally created a file with no extension and I chose the wrong file type association. Text Document I think. I renamed it to have the .js extension which is what I wanted, but now it's stuck without any syntax highlighting. WebStorm doesn't treat it as a javascript file. I can't find anywhere to change how WebStorm treats this file. I've tried renaming it and renaming it back and that doesn't work. With any other name, (with a .js extension) it treats it as a javascript file, but not as the original name.
我该如何解决这个问题?WebStorm 文档没有帮助.
How can I fix this? The WebStorm documentation is no help.
推荐答案
经过大约一个小时的搜索和折腾,我找到了解决方案:
After like an hour of searching and screwing around I found a fix:
我将文件(通过重构命令)重命名为临时文件名.然后我用正确的名称创建了一个带有 .js 扩展名的新文件并且它起作用了,然后我将代码从原始文件复制到了具有正确扩展名的新创建的文件中.
I renamed the file (through the refactor command) to a temporary file name. Then I created a new file with the correct name with the .js extension and it worked, then I copied the code from the original to the newly created file with the correct extension.
我想选择新的 javascript 文件"并做同样的事情也可以.
I imagine selecting "new javascript file" and doing the same thing would also work.
这篇关于如何更改 WebStorm 中现有文件的文件类型关联?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!