哪些文本编辑器有格式代码选项?

发布于 2024-08-06 12:35:37 字数 422 浏览 3 评论 0原文

我正在寻找具有 NetBeans 或 Intellij 等代码格式的基本文本编辑器。

在 NetBeans IDE 和 Intellij IDE 中,您可以选择格式化代码。 像这样,

if( a == b )
{
                          bla;
bla;
              bla;

}

使用此功能后,它将如下所示:

if( a == b ){
          bla;
          bla;
          bla;
}

PS 我想要 NetBeans 和 Intellij 提供的相同功能。 我想要一个文本编辑器,因为我刚开始接触 Java,而且 IDE 对于初学者来说不太好。

I'm looking for a basic text-editor with code format like NetBeans or Intellij.

In NetBeans IDE and Intellij IDE you have the option format code.
Something like this,

if( a == b )
{
                          bla;
bla;
              bla;

}

after using this feature it will look like this:

if( a == b ){
          bla;
          bla;
          bla;
}

P.S. I want the same thing which NetBeans and Intellij are offering.
I want a text editor, because I'm at beginning with Java and the IDE's are not very good for a beginner.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

用心笑 2024-08-13 12:35:37

大多数文本编辑器允许您将热键绑定到命令。我使用 SciTE 并将调用绑定到 astyle 将当前文档设为功能键。 Astyle 可以很好地格式化大多数语言(它使 C99 指定的初始化器成为猪耳朵,但除此之外它还不错)。还可以使用其他源代码格式化程序。

Most text editors let you bind hot keys to commands. I use SciTE and bind a call to astyle on the current document to a function key. Astyle formats most of the languages reasonable well ( it makes a pig's ear of C99 designated initialisers, but apart from that it's good ) . Other source code formatters are available.

故人的歌 2024-08-13 12:35:37

几乎所有程序员的编辑器或 IDE 都会重新格式化代码。您在问题中提到了 NetBeans 和 InelliJ,但没有提到为什么它们不能满足您的需求。如果没有更多信息,您可能得到的只是一个编辑器列表,这对您没有多大帮助。

具体来说,您的要求是什么?

Almost any programmer's editor or IDE will re-format code. You mention NetBeans and InelliJ in your question, but you don't mention why they aren't meeting your needs. Without more information, all you're likely to get is a list of editors, which isn't going to help you much.

What, specifically, are your requirements?

猥︴琐丶欲为 2024-08-13 12:35:37

我不确定它是否会改变大括号的位置(在同一行与单独的行上),但 vim(文本编辑器,可在 doze 和 *nix 上使用)将修复缩进。

我发现“==”命令是最有用的。或者,在命令模式下,转到文件顶部并调用“=G”将正确缩进整个文件。

vim 缩进选项总结:
http://vim.wikia.com/wiki/Indenting_source_code

vim 缩进选项的官方文档:
http://www.vim.org/htmldoc/indent.html

I'm not sure if it will change the location of curly-braces (on the same line versus a separate line) but vim (a text editor, available on doze and *nix) will fix indentation.

I find the "==" command to be the most useful. Or, in command mode, going to the top of the file and invoking "=G" will properly indent the entire file.

Summary of vim indentation options:
http://vim.wikia.com/wiki/Indenting_source_code

Official documentation of vim indentation options:
http://www.vim.org/htmldoc/indent.html

灼痛 2024-08-13 12:35:37

Zeus 编辑器可以通过运行 脚本,这些脚本也可以绑定到键盘。

The Zeus editor can do this by running a macro script and these scripts can also be bound to the keyboard.

千仐 2024-08-13 12:35:37

检查Code-Chameleon
它支持多种语言。

Check Code-Chameleon.
It Supports many languages.

似梦非梦 2024-08-13 12:35:37

emacs 支持 fill-region ,它将格式化任何选定的区域根据当前模式编码。

您可能会发现 mark-whole-buffermark-sexp 在此上下文中很有用。


对于类 C 语言,支持大量不同的风格。阅读与变量 c-file-style 相关的文档。 (尽管我无法理解为什么有人使用 One True Brace 风格......)

emacs supports fill-region which will format any selected region of code according to the current mode.

You might find mark-whole-buffer and mark-sexp useful in this context.


For c-like languages there is support for a vast panoply of different styles. Read the documentation associated with the variable c-file-style. (Though why anyone would not use the One True Brace Style is beyond me...)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文