Intellij idea 为什么@complete快捷方式在类定义中不起作用?

Intellij idea 为什么@complete快捷方式在类定义中不起作用?,intellij-idea,Intellij Idea,我开始学习kotlin,从2018年开始阅读“kotlin big nerd ranch guide”(我知道这本书有点老了,如果你有新的/更好的书,我会接受建议,尽管我认为这本书相当不错;回到问题描述) 我遇到了一个问题,在intelliJ IDEA中,我必须在新创建的kotlin类中移动到类定义之外,以便能够对主函数使用autocomplete,例如,在许多其他情况下,这就是为什么我担心这个问题。当我开始使用一个新的IDE时,我要学习如何提高效率 /*If the caret is here

我开始学习kotlin,从2018年开始阅读“kotlin big nerd ranch guide”(我知道这本书有点老了,如果你有新的/更好的书,我会接受建议,尽管我认为这本书相当不错;回到问题描述)

我遇到了一个问题,在intelliJ IDEA中,我必须在新创建的kotlin类中移动到类定义之外,以便能够对主函数使用autocomplete,例如,在许多其他情况下,这就是为什么我担心这个问题。当我开始使用一个新的IDE时,我要学习如何提高效率

/*If the caret is here and I type "main" and then press TAB, the IDE replaces
  the word with "fun main(...) {...}", as it's defined in my settings (Keymap), I can
  also use ctrl+shift+intro and the IDE also replaces the main word with the text 
  I just pasted.*/
class NyetHack {
    /*If the caret is here, and I want to type "main" and then press TAB, 
      or ctrl+shift+intro, it just doesn't seem to recognize the "main" word, 
      the IDE seems to believe I'm trying to autocomplete something it can't.*/
}
我正在使用intelliJ IDEA 2020.3.1社区版

  • 为什么会这样

  • 我能修好这个吗


如果你附上一个屏幕截图,你会更清楚你在做什么,什么时候发生,但我想你说的是完成

每个实时模板片段都有一个适用的上下文:上下文可以是类、注释、语句、表达式等。
main
可在源文件顶级上下文中找到:


我知道这与上下文有关,但我没有使用任何其他IDE面对问题中描述的情况。我在windows中检查了设置,自己也找不到上下文,也找不到live templates选项卡。我到家后会试试的。谢谢