Textmate 中的 Java 代码格式化

发布于 2024-08-09 06:58:10 字数 92 浏览 4 评论 0原文

有没有一种方法/捆绑/快捷方式可以在 TextMate 中格式化 Java 源代码? (正如我们在 Eclipse 中使用 Shift+Command+F 所做的那样)。

Is there a way/bundle/shortcut to format the Java Source in TextMate?
(As we do with Shift+Command+F in Eclipse).

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

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

发布评论

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

评论(4

赢得她心 2024-08-16 06:58:10

它必须

Command + Option + [

也是文本>缩进选择

It must be

Command + Option + [

which is also Text>Indent Selection

在你怀里撒娇 2024-08-16 06:58:10

警告:读到最后,我意识到格式是它所没有的功能。我目前使用的是这个过程,然后alt+tab到Eclipse进行格式化。 TextMate 和 Eclipse 似乎都没有并发编辑同一个文件的问题,而且工作得很好。然而我意识到这不是最初的问题。

我使用 eclim 和 eclim TextMate 包。我不会撒谎,您必须运行 Eclipse 才能使用它。不过,您可以禁用 GUI 并将 Eclipse 作为无头守护程序运行,或者只是最小化 Eclipse,以防以后需要它。这是一个很好的折衷方案,并且因其为 TextMate 提供的功能而非常值得。

这给了我:

  • 代码完成
  • 自动导入缺失的类
  • Java 重命名(重构)
  • 带有构建错误的窗口

这些功能中的每一个都提供与 Eclipse 本身相同的功能。

目前该捆绑包仅支持 Java,但 eclim 本身(最初是为 vim 编写的 Eclipse 插件)支持更多功能和语言,并且正在等待合适的人来为所有内容实现 Eclipse 功能。

您可以在这里找到 eclim:
http://eclim.org/

eclim 包位于 GetBundles 中。

如果您没有 GetBundles,我推荐它。它是一个捆绑包,允许您轻松地从多个存储库下载新捆绑包,所有这些都在 TextMate 内进行。

在终端中运行以下命令来安装它:
cd ~/Library/Application\ Support/TextMate/Bundles
svn co <​​a href="http://svn.textmate.org/trunk/Review/Bundles/GetBundles.tmbundle/" rel="nofollow">http://svn.textmate.org/trunk/Review/Bundles/ GetBundles.tmbundle/

如果您不想安装它,eclim textmate 包位于此处:
https://github.com/JulianEberius/Eclim.tmbundle

运行 eclim 安装程序时,选择包含“插件”的 Eclipse 文件夹。然后,当您启动 Eclipse 时,转到 Window->Show View->Other。从“eclim”中选择“eclim”。 TextMate 包需要运行此视图才能检测 eclim 服务器。您应该在控制台窗口中看到一些信息,最后一行显示如下内容:Eclim Server Started on port 9091。如果是这样,它应该可以在 TextMate 中工作。

你知道吗,我只是去为你抓住键盘快捷键,然后意识到“格式”是我总是切换到 Eclipse 使用的那个。对此感到抱歉。但是,嘿,eclim 无论如何都很棒,也许当我有时间时我会为 TextMate 编写格式命令。源代码是用 Python 编写的,看起来相对简单。

Warning: I got to the end and realized format was the one feature this DOESN'T have. I currently use this process, and then alt+tab to Eclipse to format. Neither TextMate nor Eclipse seem to have a problem with concurrently editing the same file and it works beautifully. However I realize this wasn't the original question.

I use eclim and the eclim TextMate bundle. I'm not gonna lie, you do have to run Eclipse to use it. However you can disable the GUI and run Eclipse as a headless daemon or just minimize Eclipse in case you need it for something later. It's a good compromise and well worth it for the features it provides to TextMate.

This gives me :

  • Code Completion
  • Auto-import missing classes
  • Java Rename (Refactor)
  • Window with build errors

Each of these features provides the same functionality as Eclipse itself.

Currently the bundle only supports Java, but eclim itself (which is an Eclipse plugin originally written for vim) supports many more features and languages, and is just waiting for the right person to come along and implement Eclipse features for everything.

You can find eclim here:
http://eclim.org/

And the eclim bundle is in GetBundles.

If you don't have GetBundles, I recommend it. It's a bundle that allows you easily download new bundles from several repositories, all from within TextMate.

run these commands in terminal to install it:
cd ~/Library/Application\ Support/TextMate/Bundles
svn co http://svn.textmate.org/trunk/Review/Bundles/GetBundles.tmbundle/

If you prefer not to install it, the eclim textmate bundle is here:
https://github.com/JulianEberius/Eclim.tmbundle

When you run the eclim setup, choose the Eclipse folder that contains 'plugins'. Then, when you launch Eclipse, go to Window->Show View->Other. Choose 'eclim' from 'eclim'. This view needs to be running for the TextMate bundle to detect the eclim server. You should see some information go through the console window, with the last line saying something like: Eclim Server Started on port 9091. If so, it should work in TextMate.

You know what, I just went to grab the keyboard shortcut for you, and realized 'format' is the one I always switch to Eclipse to use. Sorry bout that. But hey, eclim is fantastic anyway and maybe when I have some time I'll write the format command for TextMate. The source is in Python and looks relatively straightforward.

混吃等死 2024-08-16 06:58:10

可能你想要的是这

Command + Shift + {

适用于任何语言

Probably what you want is this

Command + Shift + {

Works for any language

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