IntelliJ:如何强制编辑器将文件视为javascript? [英] IntelliJ: how to force editor to treat a file as javascript?

查看:176
本文介绍了IntelliJ:如何强制编辑器将文件视为javascript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在IntelliJ 10中创建一个Grails应用程序,并且有一个动态创建的javascript文件,作为Grails视图。

I'm creating a Grails app in IntelliJ 10 and have a javascript file that is created dynamically, as a Grails view.

因此javascript文件没有结束'.js'。它以'.gsp'结尾,因为它是一个吐出javascript的Groovy服务器页面。

For that reason the javascript file doesn't end in '.js'. It ends in '.gsp' because it's a Groovy Server Page that spits out javascript.

IntelliJ不知道它是一个javascript文件所以它不给我代码完成或警告。

IntelliJ doesn't know it's a javascript file so it doesn't give me code completion or warnings.

我希望我的代码完整并进行语法检查!有没有办法强制IntelliJ将此特定文件视为Javascript,而不会搞乱IntelliJ对其他地方.gsp文件的正确处理?

I want my code complete and syntax checking! Is there a way to force IntelliJ to treat this specific file as Javascript, WITHOUT messing up the IntelliJ's correct treatment of .gsp files everywhere else?

谢谢!

推荐答案

上述答案略显过时。您可以通过执行以下操作在IntelliJ 14中执行相同的操作:

The above answer is slightly outdated. You can do the same in IntelliJ 14 by doing the following:


  1. 转到首选项(Mac OSX:Cmd +逗号)

  2. 编辑器 - >下;文件类型

  3. 已识别的文件类型中突出显示 JavaScript文件(JavaScript)

  4. 注册模式下 + 按钮

  5. 输入您的正则表达式模式(例如: * .js.scala.html )并按OK

  1. Go to Preferences (Mac OSX : Cmd + Comma)
  2. Under Editor -> File Types
  3. In the Recognized File Types Highlight JavaScript files (JavaScript)
  4. Under Registered Patterns press the + button
  5. Enter your regex pattern (for example: *.js.scala.html) and press OK

干杯!

这篇关于IntelliJ:如何强制编辑器将文件视为javascript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆