Eclipse:同时使用制表符和空格进行缩进

Eclipse: use both tabs and spaces for indentation

我正在做的一个项目有如下缩进标准:

示例:

在Vim中,必要的配置是通过以下方式实现的:

:set tabstop=8 softtabstop=4 noexpandtab

如何配置 Eclipse 以自动执行此缩进标准?

我不相信 Eclipse CDT 支持这种缩进样式。

Eclipse 是开源的;您可以考虑 contributing a patch 添加对此样式的支持。

Eclipse 没有内置的插件,但看起来插件 Vrapper (Vim) 提供了您正在寻找的东西。

Vrapper > Documentation > Configuration:

  • softtabstop - When using spaces for tabs, set this to the number of spaces inserted for each Tab key press and hitting Backspace in InsertMode will delete that many spaces as if you had deleted a tab character.
  • tabstop - Used by i_ctrl-t, i_ctrl-d, and :retab. Determines number of spaces to replace each tab character with when xpandtab is enabled.
  • expandtab/noexpandtab - Used by i_ctrl-t, i_ctrl-d, and :retab. Determines whether :retab should replace all tabs with spaces (true) or spaces with tabs (false). Also determines whether i_ctrl-t and i_ctrl-d will replace tabstop spaces with a tab.

Eclipse 本身就支持这个。

我的eclipse版本:

结果(见图片评论):

第 1 步:

第 2 步:

第 3 步:

第四步(最重要的一步):