【问题标题】:Webstorm helper for requiring module需要模块的 Webstorm 助手
【发布时间】:2015-04-17 22:46:19
【问题描述】:

我正在寻找一种使用 Webstorm(快捷方式、插件、意图......)轻松地 require 模块的方法。这是我的用例:

  • 假设我的光标位于我的 JS 文件中某个未知变量 myVar 的末尾。
  • 当我按下快捷方式时,我会跳转到文件的顶部,var myVar = require('') 会插入到空字符串中。
  • 然后我输入模块的名称并按回车键。
  • 然后光标回到变量的末尾。

有没有办法做到这一点?

【问题讨论】:

标签: webstorm commonjs


【解决方案1】:

请为WEB-14430投票。 您可以尝试开发自定义意图 - 代码意图将常规 API 用于意图。意图类需要实现 IntentionAction 接口并使用 plugin.xml 中的 bean 注册 (http://confluence.jetbrains.com/display/IDEADEV/Developing+Custom+Language+Plugins+for+IntelliJ+IDEA) 请参阅https://github.com/JetBrains/intellij-community/blob/master/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/control/SplitIfIntention.java - Groovi 的意图示例。

另请参阅http://confluence.jetbrains.com/display/IDEADEV/PluginDevelopmenthttp://devnet.jetbrains.com/message/5298765

Live Templates 是另一种选择,但它只允许将某些缩写扩展为代码 sn-p - 无跳转等 - sn-p 将在“就地”扩展

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-04-07
    • 2011-09-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多