JetBrains GoLang IDE。如何删除最后一个空行以及如何添加空行?
JetBrains GoLang IDE. How to remove last empty line and how to add empty lines?
我正在使用 JetBrains GoLang IDE,但不知为何没有应用几个参数。
- 我想删除最后一行
- 我希望能够在中间添加空行
package main
>
> I want an empty line
import (...)
func main() {
...
...
}
> I don't want this line
我没有看到 PyCharm 和 WebStorm 存在此类问题,我想这是 GoLang 的功能。
我试过 EditorConfig
插件设置,但它根本不起作用
root = true
[*]
charset = utf-8
tab_width = 4
end_of_line = lf
indent_size = 4
indent_style = space
max_line_length = 120
insert_final_newline = false
ij_continuation_indent_size = 8
我知道可能有一些标准,但这很烦人,我习惯了不同的代码风格
GoLand 的新版本在保存时使用 gofmt(Command/Ctrl+S 或任何操作,例如切换到不同的 window ) 以这种方式重新格式化您的文件。
另一方面,GoLand 有一个 built-in 格式化程序 (Code | Reformat Code),其格式化代码的方式与 gofmt
相同,但是允许您通过 Preferences/Settings 更改某些样式设置 |编辑|代码风格 |去.
要禁用这些功能,您可以禁用两项:
- Preferences/Settings |工具 |保存操作 |重新格式化代码。
- Preferences/Settings |编辑|代码风格 |去 |其他 | 运行 gofmt 关于代码重新格式化。
它将允许您使用自定义代码样式,直到您手动 运行 gofmt
或 重新格式化代码 操作。
无论如何,请记住 gofmt
是 Go 世界中的 de-facto 标准,不建议在没有严重原因的情况下使用自定义代码样式,例如Effective Go 说:
Formatting issues are the most contentious but the least consequential. People can adapt to different formatting styles but it's better if they don't have to, and less time is devoted to the topic if everyone adheres to the same style. The problem is how to approach this Utopia without a long prescriptive style guide.
With Go we take an unusual approach and let the machine take care of most formatting issues. The gofmt program (also available as go fmt, which operates at the package level rather than source file level) reads a Go program and emits the source in a standard style of indentation and vertical alignment, retaining and if necessary reformatting comments. If you want to know how to handle some new layout situation, run gofmt; if the answer doesn't seem right, rearrange your program (or file a bug about gofmt), don't work around it.
我正在使用 JetBrains GoLang IDE,但不知为何没有应用几个参数。
- 我想删除最后一行
- 我希望能够在中间添加空行
package main
>
> I want an empty line
import (...)
func main() {
...
...
}
> I don't want this line
我没有看到 PyCharm 和 WebStorm 存在此类问题,我想这是 GoLang 的功能。
我试过 EditorConfig
插件设置,但它根本不起作用
root = true
[*]
charset = utf-8
tab_width = 4
end_of_line = lf
indent_size = 4
indent_style = space
max_line_length = 120
insert_final_newline = false
ij_continuation_indent_size = 8
我知道可能有一些标准,但这很烦人,我习惯了不同的代码风格
GoLand 的新版本在保存时使用 gofmt(Command/Ctrl+S 或任何操作,例如切换到不同的 window ) 以这种方式重新格式化您的文件。
另一方面,GoLand 有一个 built-in 格式化程序 (Code | Reformat Code),其格式化代码的方式与 gofmt
相同,但是允许您通过 Preferences/Settings 更改某些样式设置 |编辑|代码风格 |去.
要禁用这些功能,您可以禁用两项:
- Preferences/Settings |工具 |保存操作 |重新格式化代码。
- Preferences/Settings |编辑|代码风格 |去 |其他 | 运行 gofmt 关于代码重新格式化。
它将允许您使用自定义代码样式,直到您手动 运行 gofmt
或 重新格式化代码 操作。
无论如何,请记住 gofmt
是 Go 世界中的 de-facto 标准,不建议在没有严重原因的情况下使用自定义代码样式,例如Effective Go 说:
Formatting issues are the most contentious but the least consequential. People can adapt to different formatting styles but it's better if they don't have to, and less time is devoted to the topic if everyone adheres to the same style. The problem is how to approach this Utopia without a long prescriptive style guide.
With Go we take an unusual approach and let the machine take care of most formatting issues. The gofmt program (also available as go fmt, which operates at the package level rather than source file level) reads a Go program and emits the source in a standard style of indentation and vertical alignment, retaining and if necessary reformatting comments. If you want to know how to handle some new layout situation, run gofmt; if the answer doesn't seem right, rearrange your program (or file a bug about gofmt), don't work around it.