gpt4 book ai didi

intellij-idea - Kotlin 的样式指南设置

转载 作者:IT老高 更新时间:2023-10-28 13:33:23 29 4
gpt4 key购买 nike

我已经开始大量使用 Koltin,并且在代码格式化方面有些吃力。

虽然有官方coding conventions指南,但我想知道您是否可以获取/导入和使用 IntelliJ 的任何公共(public)可用样式指南设置(例如 google codestyle 用于 Java)?

最佳答案

无需抓取/导入它们,它们内置于 IntelliJ IDEA 的 Kotlin 语言支持插件中。

您可以重新格式化 Kotlin 源代码,就像用 Java 或其他支持的语言编写代码一样。

来自 IntelliJ IDEA 2016.2 Help :: Reformatting Source Code :

Basics

IntelliJ IDEA lets you reformat source code to meet the requirements of your code style. IntelliJ IDEA will lay out spacing, indents, keywords etc. Reformatting can apply to the selected text, entire file, or entire project.

It is also possible to apply reformatting to the parts of the source code only, using the formatting markers.

Reformatting code

To reformat code for a directory, follow these steps:

  1. In the Project tool window, select a module or directory you want to apply your reformatting to.
  2. From the main menu, select Code | Reformat Code or press Ctrl+Alt+L.

    Alternatively, in the Project tool window, right-click the directory and from the context menu, select Reformat Code.

  3. In the Reformat Code dialog box, specify the necessary options and filters for you reformatting and click Run.

Reformatting code for the current file

To reformat code for the current file, follow these steps:

  1. In the editor of the currently opened file, press Ctrl+Shift+Alt+L.

    Note that if you select Code | Reformat Code from the main menu or press Ctrl+Alt+L, IntelliJ IDEA will try to reformat the source code automatically without opening the Reformat File dialog.

  2. In the Reformat File dialog, specify options for the reformatting and click Run.

关于intellij-idea - Kotlin 的样式指南设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39512679/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com